Questions tagged [keras-2]

with a new API.

Keras API will now become available directly as part of

264 questions
6
votes
1 answer

Create model using one - hot encoding in Keras

I am working on a sentence classification problem and try to solve using Keras. The total unique words in the vocabulary is 36. In this case, the total vocab is [W1,W2,W3....W36] So, if I have a sentence with words as [W1 W2 W6 W7 W9], if I encode…
Timothy Rajan
  • 1,947
  • 8
  • 38
  • 62
6
votes
1 answer

Keras ModelCheckpoint monitor multiple values

I want to use Keras ModelCheckpoint callback to monitor several parameters ( I have a multi-task network). Is it possible with just one callback ? Or do I need to do that in many callbacks ?? The ckechpoint creation : checkpointer =…
Lilo
  • 640
  • 1
  • 9
  • 22
6
votes
1 answer

Use "Flatten" or "Reshape" to get 1D output of unknown input shape in keras

I want to use the keras layer Flatten() or Reshape((-1,)) at the end of my model to output an 1D vector like [0,0,1,0,0, ... ,0,0,1,0]. Sadly there is an problem because of my unknown input shape which is: input_shape=(4, None, 1))). So typically…
Fabian
  • 3,139
  • 2
  • 23
  • 49
6
votes
1 answer

Keras 2 fit_generator UserWarning: `steps_per_epoch` is not the same as the Keras 1 argument `samples_per_epoch`

I'm using Keras 2.0.8 with Python 3 kernel in Jupyter Notebook. My backend is TensorFlow 1.3 and I'm developing on Mac. Whenever I'm using fit_generator() I'm getting following…
Jan Slominski
  • 2,968
  • 4
  • 35
  • 61
6
votes
0 answers

Implementing adversarial training in keras

I would like to implement an adversarial network with a classifier whose output is connected to an adversary that has to guess a specific feature of the inputs to the classifier (a nuisance parameter) based on the output of the classifier (a…
aniromi
  • 95
  • 7
5
votes
1 answer

how to split up tf.data.Dataset into x_train, y_train, x_test, y_test for keras

If I have a dataset dataset = tf.keras.preprocessing.image_dataset_from_directory( directory, labels="inferred", label_mode="int", class_names=None, color_mode="rgb", batch_size=32, image_size=(32, 32), shuffle=True, …
sameerp815
  • 51
  • 1
  • 4
5
votes
1 answer

Keras 2: Using lambda function in "Merge" layers

I am trying to implement this merge layer: policy = merge([out1, out2], mode = lambda x: x[0]-K.mean(x[0])+x[1], output_shape = (out_node,)) However, "merge" is no longer present in Keras 2. You can only access public standarized "Merge" layers,…
olinarr
  • 261
  • 3
  • 13
5
votes
0 answers

Gradually update weights of custom loss in Keras during training

I defined a custom loss function in Keras (tensorflow backend) that is comprised of reconstruction MSE and the kullback leibler divergence between the learned probability distribution and a standard normal distribution. (It is for a variational…
Kate A Baumli
  • 123
  • 1
  • 6
5
votes
1 answer

Weighing Training Data for Keras

Problem I want to train a keras2 neural network (theano backend) with data of variable relevance. That means some of the samples are less important than others. They shall affect the training less than others. However I'm not able to simply omit…
ascripter
  • 5,665
  • 12
  • 45
  • 68
5
votes
2 answers

How do I use categorical_hinge in Keras?

Maybe a very dumb question but I can't find an example how to use categorical_hinge in Keras. I do classification and my target is shape(,1) with values [-1,0,1] so I have 3 categories. Using the functional API I have set up my output layer like…
Manngo
  • 829
  • 7
  • 24
5
votes
1 answer

When is Layer.build() invoked in source code in keras?

Every derived class of Layer class in keras has build() definition. build() is place where we assign weights to the keras layer. When is this function invoked internally? I am unable to find any piece of code which may be callling it In __call_()…
abhishek jha
  • 1,065
  • 4
  • 21
  • 41
5
votes
4 answers

Keras: ImportError: `save_model` requires h5py even thought the code already imported h5py

I ran into some trouble when trying to save a Keras model: Here is my code: import h5py from keras.models import load_model try: import h5py print ('import fine') except ImportError: h5py = None left.save('left.h5') # creates a HDF5…
Edamame
  • 23,718
  • 73
  • 186
  • 320
5
votes
1 answer

How to use InceptionV3 bottlenecks as input in Keras 2.0

I want to use bottlenecks for transfer learning using InceptionV3 in Keras. I've used some of the tips on creating, loading and using bottlenecks from https://blog.keras.io/building-powerful-image-classification-models-using-very-little-data.html My…
Ivo
  • 1,768
  • 20
  • 19
5
votes
1 answer

Using Masking-layer with ConvLSTM2D-layer in Keras

I am trying to mask missing data from a Convolutional LSTM layer using Keras (2.0.6) with TensorFlow backend (1.2.1): import keras from keras.models import Sequential from keras.layers import Masking, ConvLSTM2D n_timesteps = 10 n_width =…
niklascp
  • 816
  • 5
  • 10
4
votes
1 answer

How can I create a Keras Learning Rate Schedule that updates based upon batches rather than epochs

I'm working with Keras, and trying to create a Learning Rate Scheduler that schedules on the basis of number of batches processed, instead of number of epochs. To do this, I've inserted the scheduling code into the get_updates method of my…
user1245262
  • 6,968
  • 8
  • 50
  • 77
1 2
3
17 18