Questions tagged [keras-2]

with a new API.

Keras API will now become available directly as part of

264 questions
4
votes
3 answers

how to properly saving loaded h5 model to pb with TF2

I load a saved h5 model and want to save the model as pb. The model is saved during training with the tf.keras.callbacks.ModelCheckpoint callback function. TF version: 2.0.0a edit: same issue also with 2.0.0-beta1 My steps to save a pb: I first…
Florida Man
  • 2,021
  • 3
  • 25
  • 43
4
votes
1 answer

Keras dimension mismatch in last layer of autoencoder

I want to reuse an convolutional autoencoder (with the mnist datasets with 10 digits/categories) from https://blog.keras.io/building-autoencoders-in-keras.html and put it into a modified version where images are loaded from diretories with…
tardis
  • 1,280
  • 3
  • 23
  • 48
4
votes
2 answers

Getting x_test, y_test from generator in Keras?

For certain problems, the validation data can't be a generator, e.g.: TensorBoard histograms: If printing histograms, validation_data must be provided, and cannot be a generator. My current code looks like: image_data_generator =…
A T
  • 13,008
  • 21
  • 97
  • 158
4
votes
1 answer

Error when using Keras for transfer learning: AttributeError: 'list' object has no attribute 'dtype'

I am getting following error AttributeError: 'list' object has no attribute 'dtype' when running the following script which uses transfer learning in Keras to retrain and fine tune the last layer in the Inception V3 model. For my dataset I'm…
Ryan Chase
  • 2,384
  • 4
  • 24
  • 33
4
votes
1 answer

Noisy validation loss in Keras when using fit_generator

Any idea about why our training loss is smooth and our validation loss is that noisy (see the link) across epochs? We are implementing a deep learning model for diabetic retinopathy detection (binary classification) using the data set of fundus…
4
votes
0 answers

Is it possible to use different padding for each dimension in conv nets wit keras

I would like to use different paddings for different dimensions. In my case I'm using a 3dconvnet. The reason is that I would like to control how how the receptive field and axis squashing occurs for different dimensions. E.g. I would like to have…
Josh Albert
  • 1,064
  • 13
  • 16
4
votes
1 answer

keras Input layer (Nnoe,200,3), Why there is None?input have 3 dimensions, but got array with shape (200, 3)

The acc gyro in model.fit is (200 * 3),in the Input layer shape is (200 * 3). Why is there such a problem? Error when checking input: expected acc_input to have 3 dimensions, but got array with shape (200, 3).This is a visualization of my…
xianglala
  • 41
  • 2
4
votes
3 answers

How to chain/compose layers in keras 2 functional API without specifying input (or input shape)

I would like be able to several layers together, but before specifying the input, something like the following: # conv is just a layer, no application conv = Conv2D(64, (3,3), activation='relu', padding='same', name='conv') # this doesn't work: bn =…
mitchus
  • 4,677
  • 3
  • 35
  • 70
4
votes
1 answer

Concatenate input with constant vector in keras

I am trying to concatenate my input with a constant tensor in the keras-2 function API. In my real problem, the constants depend on some parameters in setup, but I think the example below shows the error I get. from keras.layers import* from…
kgully
  • 650
  • 7
  • 16
3
votes
2 answers

TensorFlow, Keras: Replace Activation layer in pretrained model

I'm trying to replace swish activation with relu activation in pretrained TF model EfficientNetB0. EfficientNetB0 uses swish activation in Conv2D and Activation layers. This SO post is very similar to what I'm looking for. I also found an answer…
mrtpk
  • 1,398
  • 4
  • 18
  • 38
3
votes
3 answers

In using Keras Tuner with Tensorflow 2 I am getting an error : division by zero

I am experimenting with kerastuner. Here is my code with a reproducible example: import kerastuner as kt from kerastuner.tuners.bayesian import BayesianOptimization (x_train, y_train), (x_test, y_test) =…
user8270077
  • 4,621
  • 17
  • 75
  • 140
3
votes
1 answer

Getting Gradients of Each Layer in Keras 2

It's been days that I've been struggling just to simply view layers' gradients in the debug mode of Keras2. Needless to say, I have already tried codes such as: import Keras.backend as K gradients = K.gradients(model.output, model.input) sess =…
3
votes
1 answer

How to freeze selected weights in keras or tf.keras?

I am trying out something where I required to freeze some selected weights. Take this example from keras.models import Sequential from keras.layers import Dense,Input model = Sequential() model.add(Dense(4,…
Eka
  • 14,170
  • 38
  • 128
  • 212
3
votes
0 answers

Visualizing layers of autoencoder

I have created a variational autoencoder in Keras using 2D convolutions for encoder and decoder. The code is shown below. Now, I would like to visualize the individual layers or filters (feature maps) to see what the network learns. How can this be…
machinery
  • 5,972
  • 12
  • 67
  • 118
3
votes
1 answer

Keras: Using weights for NCE loss

So here is the model with the standard loss function. target = Input(shape=(1, ), dtype='int32') w_inputs = Input(shape=(1, ), dtype='int32') w_emb = Embedding(V, dim, embeddings_initializer='glorot_uniform',name='word_emb')(w_inputs) w_flat=…
pythOnometrist
  • 6,531
  • 6
  • 30
  • 50