Questions tagged [keras-2]

with a new API.

Keras API will now become available directly as part of

264 questions
3
votes
5 answers

Installed Keras with pip3, but getting the "No Module Named keras" error

I am Creating a leaf Identification Classifier using the CNN, the Keras and the Tensorflow backends on Windows. I have installed Anaconda, Tensorflow, numpy, scipy and keras. I installed keras using pip3: C:\> pip3 list | grep -i keras Keras …
ABCD
  • 379
  • 1
  • 8
  • 25
3
votes
3 answers

Get class info of Keras' ImageDataGenerator images besides parsing filename

I load hundres of images with ImageGenerator and its flow_from_dirctory-function from lets say two directories (two classes) in the validation directory (and test directory) with names "cats" and "dogs": validation_generator =…
tardis
  • 1,280
  • 3
  • 23
  • 48
3
votes
1 answer

R reshape array to include data twice from list of matrices as prep for keras

I'm trying to create a 3D array that duplicates the elements (a copy of data) with rows remaining the same for both. This is ultimately to be a keras/tensorflow lstm input array (samples, timesteps, features) of a time series, where, for different…
Chris
  • 1,647
  • 1
  • 18
  • 25
3
votes
1 answer

Keras: get training data from a saved model

Is it even possible? The model is saved by ModelCheckpoint(model_path, save_best_only=True, monitor='val_acc', mode='max', save_weights_only=False) Can I do something like this? from keras.models import load_model model =…
vogdb
  • 4,669
  • 3
  • 27
  • 29
3
votes
2 answers

How to normalize data when using Keras fit_generator

I have a very large data set and am using Keras' fit_generator to train a Keras model (tensorflow backend). My data needs to be normalized across the entire data set however when using fit_generator, I have access to relatively small batches of…
Eric Broda
  • 6,701
  • 6
  • 48
  • 72
3
votes
2 answers

Use tf.metrics in Keras?

I'm especially interested in specificity_at_sensitivity. Looking through the Keras docs: from keras import metrics model.compile(loss='mean_squared_error', optimizer='sgd', metrics=[metrics.mae,…
A T
  • 13,008
  • 21
  • 97
  • 158
3
votes
1 answer

Concatenate input with constant vector in keras. how one define the batch_size

As a follow-up from this question: Concatenate input with constant vector in keras I am trying to use the suggested solution: constant=K.variable(np.ones((1,10, 5))) constant = K.repeat_elements(constant,rep=batch_size,axis=0) And got the following…
YoavEtzioni
  • 85
  • 10
3
votes
1 answer

Binarize tensor in Keras

I need to create a loss function for Keras that works with only binary values. In wanted for to transform all the values greater than 0.5 to 1.0, so I did that: def MyLoss(y_true, y_pred: y_true_f = K.flatten(y_true) y_pred_f =…
FiReTiTi
  • 5,597
  • 12
  • 30
  • 58
3
votes
2 answers

Why the keras code get error messages when changing from Keras 1.2.2 to Keras 2.0.5

This is a piece of code I get from github for hierarchical attention network,the code is originally in Keras 1.2.2. now I have to change it to compile with Keras 2.0.5, however, it has such error messages that I could not solve. The original code is…
姬鹏飞
  • 31
  • 1
3
votes
1 answer

Keras Progress Bar not working on windows 10

I am having issues on Windows 10, Python 3 in Jupyter Notebook properly displaying the Keras progress bar. As you can see from the image attached, the output is all being concatenated as a long string with verbose=1 instead of properly backspacing…
reese0106
  • 2,011
  • 2
  • 16
  • 46
3
votes
1 answer

Error in creating custom activation that reduces the channel size with keras

I created a custom activation function with keras, which reduce the channel size by half (max-feature map activation). Here's what part of the code looks like : import tensorflow as tf import keras from keras.utils.generic_utils import…
Darshi
  • 55
  • 4
3
votes
1 answer

Keras Lambda CTC unable to get model to load

Hi I have a model which is based on this https://github.com/igormq/asr-study/tree/keras-2 that is able to just about save okay but is unable to load (either full mode or json/weights) due to the fact the loss isn't defined properly. inputs =…
robmsmt
  • 1,389
  • 11
  • 19
3
votes
1 answer

Keras for semantic segmentation, flow_from_directory() error

I was attempting to use my modification of the example code in the Keras documentation that shows how to set up image_datagen.flow_from_directory() in the case where image masks are being used in place of labels (for image segmentation, where we are…
Rafael_Espericueta
  • 495
  • 1
  • 6
  • 14
3
votes
1 answer

Custom merge layer in Keras 2.0

In keras 1 i used to write def merge_mode(branches): return #merge function Merge([...], output_shape=(num_classes,), mode=merge_mode) But now in keras 2.0 Merge is deprecated, and you can only add predefined functions like add, average,…
A. AB
  • 31
  • 2
3
votes
1 answer

Fitting a keras model when layers aren't trainable gives inconsistent results

I'm trying to determine the accuracy of my model without training and updating the weights so I've set all of my layers to trainable = False. When I run fit_generator on a generator with shuffle = False, I get consistent results each time. When I…
jvans
  • 2,765
  • 2
  • 22
  • 23