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
3 answers

Is there a DropConnect layer in Keras?

I came across an implementation of DropConnect layer in TensorLayer: http://tensorlayer.readthedocs.io/en/latest/modules/layers.html but I need a Keras equivalent. Are there any implementations for DropConnect on Keras? If not, can any existing…
Prateek Dewan
  • 1,587
  • 3
  • 16
  • 29
9
votes
2 answers

Keras: real amount of GPU memory used

I'm using Keras with Tensorflow backend and looking at nvidia-smi is not sufficient to understand how much memory current network architecture need because seems like Tensorflow just allocate all availible memory. So the question is how to find out…
mrgloom
  • 20,061
  • 36
  • 171
  • 301
9
votes
1 answer

Too strong regularization for an autoencoder (Keras autoencoder tutorial code)

I'm using this tutorial about autoencoders: https://blog.keras.io/building-autoencoders-in-keras.html All the code is working, however the performance is very bad (the results are blurred) when I set 10e-5 for the regularization parameter, which is…
ahstat
  • 539
  • 1
  • 7
  • 16
9
votes
9 answers

Jupyter can't find keras' module

I have installed Tensorflow and Keras by Anaconda (on Windows 10), I have created an environment where I am using Python 3.5.2 (the original one in Anaconda was Python 3.6). When I try to execute import keras as ks, I get ModuleNotFoundError: No…
Simone
  • 4,800
  • 12
  • 30
  • 46
9
votes
1 answer

Keras: Exception: Received unknown keyword arguments: {'epochs': 100}

I am trying to replicate the code on http://machinelearningmastery.com/time-series-prediction-lstm-recurrent-neural-networks-python-keras/ (first example). The code can be found in the part "LSTM Networks for Regression". However, my question mainly…
Peter Series
  • 289
  • 3
  • 9
9
votes
1 answer

Python loop taking more time at each iteration

I made a for loop which strangely increases in duration at each iteration although the amount of variables manipulated remains constant. The code is below with: X [N*F]: a numpy array with N samples containing F variables (features); parts [N]: a…
Tabs
  • 154
  • 6
9
votes
2 answers

Defining an AUC metric for Keras to support evaluation of validation dataset

I am trying to implement an AUC metric for Keras so that I have AUC measurement after my validation set runs during a model.fit() run. I define the metric as such: def auc(y_true, y_pred): …
Avedis
  • 443
  • 3
  • 13
9
votes
2 answers

Keras embedding layer masking. Why does input_dim need to be |vocabulary| + 2?

In the Keras docs for Embedding https://keras.io/layers/embeddings/, the explanation given for mask_zero is mask_zero: Whether or not the input value 0 is a special "padding" value that should be masked out. This is useful when using recurrent…
Nigel Ng
  • 543
  • 1
  • 7
  • 21
9
votes
1 answer

Many to many sequence prediction with different sequence length

My problem is to predict a sequence of values (t_0, t_1, ... t_{n_post-1}) given the previous timesteps (t_{-n_pre}, t_{-n_pre+1} ... t_{-1}) with Keras' LSTM layer. Keras supports the the following two cases well: n_post == 1 (many to one…
Isa
  • 1,121
  • 3
  • 10
  • 17
9
votes
2 answers

How to use OpenCV functions in Keras Lambda Layer?

I am trying to use a function that uses some OpenCV function on the image. But the data I am getting is a tensor and I am not able to convert it into an image. def image_func(img): img=cv2.cvtColor(img,cv2.COLOR_BGR2YUV) …
kauDaOtha
  • 1,140
  • 1
  • 14
  • 23
9
votes
2 answers

keras model.fit_generator() several times slower than model.fit()

Even as of Keras 1.2.2, referencing merge, it does have multiprocessing included, but model.fit_generator() is still about 4-5x slower than model.fit() due to disk reading speed limitations. How can this be sped up, say through additional…
mikal94305
  • 4,663
  • 8
  • 31
  • 40
9
votes
1 answer

Keras: Tokenizer with fit_generator() on text data

I am creating a neural net on a very large text dataset using keras. To build the model and make sure everything was working, I read a fraction of the data into memory, and use the built in keras 'Tokenizer' to do the necessary preprocessing stuff,…
Ben F
  • 153
  • 2
  • 7
9
votes
1 answer

Keras intermediate layers output

I'm trying to get the intermediate layers output when using functional API of Keras. I'm able to get the output when using the standard Sequential API, but not with the functional API. I'm working on this working toy example: from keras.models…
Miguel
  • 2,738
  • 3
  • 35
  • 51
9
votes
2 answers

Assign ImageDataGenerator result to Numpy array

I'm using the ImageDataGenerator inside Keras to read a directory of images. I'd like to save the result inside a numpy array, so I can do further manipulations and save it to disk in one file. flow_from_directory() returns an iterator, which is why…
pietz
  • 2,093
  • 1
  • 21
  • 23
9
votes
1 answer

TypeError: 'Tensor' object is not callable

I'm trying to display the output of each layer of the convolutions neural network. The backend I'm using is TensorFlow. Here is the code: import .... from keras import backend as K model = Sequential() model.add(Convolution2D(32, 3, 3, input_shape…