Questions tagged [keras-2]

with a new API.

Keras API will now become available directly as part of

264 questions
3
votes
0 answers

Keras: load existing weights into a Batchnormalization layer

I've got a fully-convolutional, pretrained model in a .h5 file. Now I would like to change the input resolution and train again. My current approach is to go through all the layers, create a new layer and assign the pretrained weights. Here is a…
lhk
  • 27,458
  • 30
  • 122
  • 201
3
votes
1 answer

How does keras basic optimizer works?

Here is part of get_updates code from SGD from keras(source) moments = [K.zeros(shape) for shape in shapes] self.weights = [self.iterations] + moments for p, g, m in zip(params, grads, moments): v = self.momentum * m - lr * g # velocity …
oak
  • 2,898
  • 2
  • 32
  • 65
3
votes
0 answers

Predicting Multiple Time Steps in a Time Series using LSTM in Keras

I want to forecast, for example, k next points of a time series using LSTM in Keras. I construct a data set starting from the beginning of a list containing all the points by selecting 0:p-1 points as input features and next k points i.e. p:p+k-1 as…
Morteza Mashayekhi
  • 934
  • 11
  • 23
2
votes
0 answers

Target array shape in Keras

I am trying to build a model which classify network attacks (DDoS or BENIGN attack). For this, I am using "ISCX 2017" dataset from https://www.unb.ca/cic/datasets/ids-2017.html. Everything goes fine until I fit the model. I am getting this error…
Tonikami04
  • 177
  • 1
  • 2
  • 14
2
votes
1 answer

Is this possible with tf.tensor_scatter_nd_add

A simple example of the following use of tf.tensor_scatter_nd_add is giving me problems. B = tf.tensor_scatter_nd_add(A, indices, updates) tensor A is (1,4,4) A = [[[1. 1. 1. 1.], [1. 1. 1. 1.], [1. 1. 1. 1.], [1. 1. 1. 1.]]] the…
2
votes
2 answers

TensorFlow 2: RuntimeError: Cannot use a constraint function on a sparse variable

I define an embedding object with embeddings_constraint: from tensorflow.keras.layers import Embedding from tensorflow.keras.constraints import UnitNorm . . . emb = Embedding(input_dim, output_dim, name='embedding_name',…
Belphegor
  • 4,456
  • 11
  • 34
  • 59
2
votes
2 answers

How to take the trainable parameters into a loss function in Tensoflow.Keras

I'm trying to implement a loss function where variables in Convolutional layers are required for calculation. There's one method given by the official documents that involve variables in the loss function: If this is not the case for your loss…
PokeLu
  • 767
  • 8
  • 17
2
votes
1 answer

Data-augmentation generators not working with TensorFlow 2.0

I am trying to train model with image data-augmentation generators on TensorFlow 2.0, after downloading Kaggle's cats_vs_dogs dataset using below code. train_datagen = ImageDataGenerator(rescale=1. / 255, …
rahiakela
  • 21
  • 4
2
votes
1 answer

How does Keras 2 aggregate the results of custom metrics?

The Keras documentation gives, at the very end, an example of a function that gets y_true and y_pred and returns a value, once per batch, and that value gets shown during training. If I try to implement the Keras Metric class, and look at the other…
pchr8
  • 115
  • 7
2
votes
1 answer

Keras --- Training freezes during fit_generator()

I am trying to train my 6000 train dataset and 1000 validation dataset but I have a problem: the program just freezes and hangs during training without any error message . 1970/6000 [========>.....................] - ETA: 1:50:11 - loss: 1.2256 -…
Lusus
  • 23
  • 1
  • 4
2
votes
1 answer

Difference of calling the Keras pretrained model without including top layers

What is the difference of calling the VGG16 model with or without including top layers of the model? I wonder, why the input parameters to the layers are not shown in the model summary when the model is called without including the top layers. I…
Nhqazi
  • 732
  • 3
  • 12
  • 30
2
votes
0 answers

Image Data Generator: how can I test the parallelism?

I've created an ImageDataGenerator for Keras, and I would like to make sure that it runs in parallel, meaning it generates a batch while Keras processes the previous generated batch. But the parallelism is handled directly by Keras. Is there simple…
FiReTiTi
  • 5,597
  • 12
  • 30
  • 58
2
votes
1 answer

Keras TimeDistributed Conv1D Error

This is my code: cnn_input = Input(shape=(cnn_max_length,)) emb_output = Embedding(num_chars + 1, output_dim=32, input_length=cnn_max_length, trainable=True)(cnn_input) output = TimeDistributed(Convolution1D(filters=128, kernel_size=4,…
user9459060
2
votes
1 answer

Fine-tuning of Keras autoencoders of cat images

I want to use autoencoders on real life photos (and not simple MNIST digits). I have taken the cats and dog dataset and train with it. My parameters are: I stick with a grayscale and a scaled down verson of 128x128 px image and do some…
tardis
  • 1,280
  • 3
  • 23
  • 48
2
votes
1 answer

Concatenate multiple Convolution Layers

Text classification by extracting tri-grams and quad-grams features of character level inputs using multiple concatenated CNN layers and passing it to BLSTM layer submodels = [] for kw in (3, 4): # kernel sizes model = Sequential() …
Roma Jain
  • 333
  • 4
  • 13