Questions tagged [keras]

Keras is a popular, open-source deep learning API for Python built on top of TensorFlow and is useful for fast implementation. Topics include efficient low-level tensor operations, computation of arbitrary gradients, scalable computations, export of graphs, etc.

What is Keras?

Keras is a popular, open-source deep learning API for Python built on top of TensorFlow and is useful for fast implementation. Topics include efficient low-level tensor operations, computation of arbitrary gradients, scalable computations, export of graphs, etc.


New to Keras?

There are various resources including books, tutorials/workshops, etc. for those looking to learn how to use Keras.

Introductions on the Keras website:

Introduction to Keras for Engineers

Introduction to Keras for Researchers

A popular introductory book is:

Deep Learning with Python, by François Chollet.


Tag usage

When posting questions about Keras, please take the following into consideration:

  • When tagging questions with the tag, users should make sure to post sufficient information regarding model construction (layers, input shape, activation functions, etc.) and include all other relevant tags that pertain to the specific topic at hand.

  • Explicit programming related questions are more suitable for Stack Overflow and should not be posted on Stack Exchange Data Science.

  • Questions should include sufficient details and clarity to be able to provide support for the problem at hand. This includes linking to underlying data used, providing code used for the model's construction, highlighting relevant outputs, etc.


External Resources

Keras: Documentation Page


Important Links

Issue Tracker: https://github.com/keras-team/keras/issues

2722 questions
24
votes
6 answers

Keras -- Transfer learning -- changing Input tensor shape

This post seems to indicate that what I want to accomplish is not possible. However, I'm not convinced of this -- given what I've already done, I don't see why what I want to do can not be achieved... I have two image datasets where one has images…
aweeeezy
  • 501
  • 2
  • 5
  • 9
11
votes
1 answer

What is the significance of model merging in Keras?

I have learned that Keras has a functionality to "merge" two models according to the following: from keras.layers import Merge left_branch = Sequential() left_branch.add(Dense(32, input_dim=784)) right_branch =…
Hendrik
  • 8,587
  • 17
  • 42
  • 55
10
votes
3 answers

What is the correct way to call Keras flow_from_directory() method?

In the following article there is an instruction that dataset needs to be divided into train, validation and test folders where the test folder should not contain the labeled subfolders. Instead it should only contain a single folder (i.e.…
Tauno
  • 799
  • 2
  • 9
  • 9
6
votes
2 answers

Keras custom loss function as True Negatives by (True Negatives plus False Positives)

I have some model for which I can construct the confusion matrix, although I need a custom loss function which will be as: true negatives (TN): We predicted no, and it is no. false positives (FP): We predicted yes, but it is no. My loss function…
Nikhil Verma
  • 191
  • 1
  • 1
  • 9
6
votes
2 answers

Keras: visualizing the output of an intermediate layer

I have read the docs here and I understand the general idea. I am able to visualize the weights of the intermediate layers. However, I'm having trouble visualize the activations. Here's what I have: I trained my model and saved the weights in a file…
StatsSorceress
  • 2,001
  • 3
  • 14
  • 30
5
votes
1 answer

Error: Input 0 is incompatible with layer flatten_1: expected min_ndim=3, found ndim=2

My code: from __future__ import absolute_import, division, print_function, unicode_literals from gensim.corpora import Dictionary from tensorflow import keras dictionary = Dictionary.load_from_text('diccionario_gensim.txt') import…
Morgoth
  • 51
  • 1
  • 1
  • 4
5
votes
2 answers

Custom weight initialization in Keras

From the comments in my previous question, I'm trying to build my own custom weight initializer for an RNN. Based on the code given here (careful - the updated version of Keras uses 'initializers' instead of 'initializations' according to fchollet),…
StatsSorceress
  • 2,001
  • 3
  • 14
  • 30
4
votes
1 answer

What is max_trials and executions_per_trial in keras-tuner

I am wondering what is the difference between max_trials & executions_per_trial in kerastuner.tuners.bayesian.BayesianOptimization function. Does execution_per_trial somehow relates to cross valdation? max_trails at first sounds like number of…
wasif
  • 73
  • 1
  • 6
4
votes
2 answers

Efficacy of model depends on scaling?

I'm trying to train a model to distinguish between two kinds of time signals, those with RTS noise, and those with only white noise. I have a simple 1D CNN that works well (92% accuracy) with one training set, but turns into a complete coin flip…
4
votes
1 answer

Why model.fit_generator in keras is taking so much time even before picking the data?

In Keras, I am training a model as in below model.fit_generator(data_generator(), samples_per_epoch = count, validation_data=(x_val, y_val), nb_epoch=50, callbacks=getCallBacks(), …
Divyanshu Shekhar
  • 569
  • 1
  • 5
  • 15
4
votes
3 answers

Error when checking : expected dense_1_input to have shape (None, 5) but got array with shape (200, 1)

I've trained a model with Keras, saved it and when I'm trying to apply it on new data, I'm encountering an error : ValueError: Error when checking : expected dense_1_input to have shape (None, 5) but got array with shape (200, 1) Here's the code…
Jed
  • 91
  • 2
  • 2
  • 6
4
votes
1 answer

Is Keras useful for professionals?

I know that Keras is developed for quick deployment. Is it just for beginners or also useful in industry for professionals?
James Bond
  • 1,195
  • 2
  • 11
  • 12
3
votes
1 answer

Does a Keras checkpointer save the best weights when using chekpoints with restore_best_weights?

I m training a sequence model in Keras using the tensorflow backend. I've also included some callbacks to save checkpoints and revert to best weights if the model starts to overfit (which it will). My question - when fitting using this set of…
Sledge
  • 254
  • 2
  • 9
3
votes
2 answers

Keras input shape returning an error

I am currently learning about Keras and have a problem with the input shape of a dense layer.I am currently trying to the mnist dataset.I understand that the input_shape for the train images is (60000,28,28) also i understand that keras ignores the…
3
votes
2 answers

Keras - Error when using HDF5Matrix to fit the model

So I define my data like this: x_train = keras.utils.io_utils.HDF5Matrix('dataset.h5', 'x_train') y_train = keras.utils.io_utils.HDF5Matrix('dataset.h5', 'y_train') x_test = keras.utils.io_utils.HDF5Matrix('dataset.h5', 'x_test') y_test =…
Jordy
  • 31
  • 4
1
2 3 4 5