Questions tagged [keras]

Keras is a neural network library providing a high-level API in Python and R. Use this tag for questions relating to how to use this API. Please also include the tag for the language/backend ([python], [r], [tensorflow], [theano], [cntk]) that you are using. If you are using tensorflow's built-in keras, use the [tf.keras] tag.

Keras is a high-level deep learning API, written in , similar in spirit to and . It is developed with a focus on enabling fast experimentation and now solely uses as backend. Additionally, it also has a interface.

Having a simple API with less capabilities, Keras is often seen as a good place to start experimenting with deep learning. For beginners, the Sequential API is easy to learn. For intermediate users, the Functional API has more capabilities and flexibility, but it comes at the cost of simplicity. For expert users, the Subclassing API enable ultimate capabilities, that should only be used in experimental settings.

Starting from TensorFlow 1.8 versions, Keras is also integrated in the TensorFlow framework. The creator of Keras, Francois Chollet, recommends that Keras should to be used from inside TensorFlow, as of TensorFlow version 2.0, since the latter package is much better maintained and will be updated in the future/less prone to errors as compared to the plain Keras library.

References:

42247 questions
9
votes
1 answer

How to use a tensorflow model extracted from a trained keras model

I want to build and train a neural network using the keras framework. I configured keras that it will use Tensorflow as a backend. After I trained the model with keras I tried to use Tensorflow only. I can access the session and get the tensorflow…
KyleReemoN-
  • 504
  • 2
  • 8
  • 16
9
votes
3 answers

Keras Implementation of Customized Loss Function that need internal layer output as label

in keras, I want to customize my loss function which not only takes (y_true, y_pred) as input but also need to use the output from the internal layer of the network as the label for an output layer.This picture shows the Network Layout Here, the…
ljklonepiece
  • 211
  • 2
  • 8
9
votes
2 answers

Keras ImageDataGenerator Slow

I am looking for the best approach to train on larger-than-memory-data in Keras and currently noticing that the vanilla ImageDataGenerator tends to be slower than I would hope. I have two networks training on the Kaggle cat's vs dogs dataset (25000…
John Cast
  • 1,771
  • 3
  • 18
  • 40
9
votes
1 answer

Center Loss in Keras

I want to implement center Loss explained in [http://ydwen.github.io/papers/WenECCV16.pdf] in Keras I started to create a network with 2 outputs such as : inputs = Input(shape=(100,100,3)) ... fc = Dense(100)(#previousLayer#) softmax =…
slegall56
  • 105
  • 1
  • 6
9
votes
1 answer

Do you need to standardize inputs if you are using Batch Normalization?

I've been playing around with batch normalization in Keras. I was wondering if batch normalization also normalizes the inputs to the neural network. Does that mean I do not need to standardize my inputs to my network and rely on BN to do it?
simeon
  • 585
  • 4
  • 15
9
votes
1 answer

Matthews Correlation Coefficient with Keras

I have a Keras model (Sequential) in Python 3: class LossHistory(keras.callbacks.Callback): def on_train_begin(self, logs={}): self.matthews_correlation = [] def on_epoch_end(self, batch, logs={}): …
ste
  • 448
  • 7
  • 14
9
votes
6 answers

PyCharm cannot find installed packages: keras

I installed pycharm-2016.1.4 in my PC running Ubuntu 14.04. I have installed Keras (a Python package) using pip install keras and PyCharm can find it before. But it cannot find Keras now. I do not modify any settings, so this problem may be wired.…
Dong Li
  • 520
  • 2
  • 7
  • 18
9
votes
2 answers

error when using keras' sk-learn API

  i'm learning keras these days, and i met an error when using scikit-learn API.Here are something maybe useful: ENVIRONMENT: python:3.5.2 keras:1.0.5 scikit-learn:0.17.1 CODE import pandas as pd from keras.layers import Input, Dense from…
xiao
  • 139
  • 1
  • 7
9
votes
2 answers

In Keras when does LSTM state reset in the call to model.predict?

The model has an LSTM as its first layer. When calling model.predict say you pass in several samples: >sam = np.array([ [[.5, .6, .3]], [[.6, .6, .3]], [[.5, .6, .3]] ]) >model.predict(sam) array([[ 0.23589483], [ 0.2327884 ], […
yalis
  • 1,508
  • 1
  • 16
  • 24
9
votes
2 answers

Implementing a Siamese NN in Keras

So I'm trying to implement this paper about a Siamese neural network: Learning a similarity metric discriminatively, with application to face verification, by Sumit Chopra, Raia Hadsell and Yann LeCun (2005). I'm using the CIFAR10 dataset instead,…
AndreyIto
  • 954
  • 1
  • 14
  • 35
9
votes
2 answers

How can a neural network architecture be visualized with Keras?

I tried the following: #!/usr/bin/env python import keras from keras.models import model_from_yaml model_file_path = 'model-301.yaml' weights_file_path = 'model-301.hdf5' # Load network with open(model_file_path) as f: yaml_string =…
Martin Thoma
  • 124,992
  • 159
  • 614
  • 958
9
votes
1 answer

Obtaining a prediction in Keras

I have successfully trained a simple model in Keras to classify images: model = Sequential() model.add(Convolution2D(32, 3, 3, border_mode='valid', input_shape=(img_channels, img_rows, img_cols), activation='relu',…
pepe
  • 9,799
  • 25
  • 110
  • 188
9
votes
2 answers

keras: how to predict classes in order?

I'm trying to predict image classes in keras (binary classification). The model accuracy is fine, but it seems that ImageDataGenerator shuffles the input images, so I was not able to match the predicted class with the original images. datagen =…
Yusuke
  • 103
  • 1
  • 3
9
votes
3 answers

Python/Keras/Theano wrong dimensions for Deep Autoencoder

I'm trying to follow the Deep Autoencoder Keras example. I'm getting a dimension mismatch exception, but for the life of me, I can't figure out why. It works when I use only one encoded dimension, but not when I stack them. Exception: Input 0…
Chris
  • 676
  • 5
  • 20
9
votes
3 answers

nvcc fatal : Cannot find compiler 'cl.exe' in PATH although Visual Studio 12.0 is added to PATH

I have followed all the instructions from https://datanoord.com/2016/02/01/setup-a-deep-learning-environment-on-windows-theano-keras-with-gpu-enabled/ but can't seem to get it work. I have added C:\Program Files (x86)\Microsoft Visual Studio…
kwotsin
  • 2,882
  • 9
  • 35
  • 62
1 2 3
99
100