Newest 'keras' Questions - Stack Overflow

Questions tagged [keras]

Keras is a minimalist, highly modular neural network library providing a high-level API in Python as well as an R interface that allows for rapid prototyping and the use of one of several computational back-ends.

0
votes
0answers
12 views

TensorFlow/Keras: How to implement (generalized) dice loss and get meaningful loss values?

I am trying to perform semantic segmentation in TensorFlow 1.10 with eager execution with the generalized dice loss function: def generalized_dice_loss(onehots_true, logits): smooth = tf.constant(...
0
votes
0answers
6 views

Input shape for LSTM which has one hot encoded data

The sample dataset contains Location point of the user. df.head() user tslot Location_point 0 0 2015-12-04 13:00:00 4356 1 0 2015-12-04 13:15:00 4356 2 0 ...
-1
votes
2answers
26 views

Val_Acc > Training_Acc, yet Val_Loss < Training_Loss – explanation?

I am training a Neural Network with one hidden layer and I get this strange behavior all the time: Val_Accuracy is bigger than Training_Acc, yet Val_Loss is smaller than Training_Loss. I do not ...
3
votes
1answer
39 views

how to use for loop in tensorflow/keras when using tf.keras functional API?

I wish to modify the CuDNNGRU Output with for loop. However, it seems like I can't do so due to the tf.GradientTape graph mode. How can i modify the CuDNNGRU in Functional API? I know that normally we ...
0
votes
0answers
27 views

How to delete an object or a model entirely from memory in Keras/Python3?

Firstly, I would like to give the memory information before the processes. pmem(rss=288796672, vms=4105973760, shared=107503616, text=2039808, lib=0, data=771235840, dirty=0) I built a model using ...
0
votes
0answers
21 views

AttributeError: 'generator' object has no attribute 'ndim'

I'm working on Triplets networks on Keras to find the image similarity. However, I'm getting an error when feeding triplets to the model. Request you to kindly help on this. Basically I'm trying to ...
1
vote
0answers
13 views

Is it ok to run a “With tf.Session as sess:” inside training_data_generator while running fit_generator?

I'm using tf.Session in tensorboard so I can't enable Eager mode. I need to extract image patches in large image by using tf.image.extract_image_patches. So in my custom training generator, I add ...
0
votes
0answers
12 views

Keras Tensorboard callback not logging scalars(loss)

I have been using keras tensorboard callbacks and it was working pretty well. This week I wrote a new code and the callback is no longer storing scalars even when I'm specifying metrics in the model....
0
votes
0answers
10 views

model.predict() function predicts the bounding box co-ordinates a little offset from the region of interest

Hi I am working on bounding box predictions using keras. I have trained my network with 501 images over 150 epochs. The input dataset consists of 501 images and when I split the data into train and ...
3
votes
0answers
43 views

How can I run a conditional neural network in Python (analogous to a clogit in R / Stata)?

I am looking to train a neural network in Keras (or tensorflow if required) that predicts which three players are designated stars in each NHL hockey game. My X matrix consists of standard box score ...
0
votes
0answers
20 views

What's wrong with the last two layers of this U-net?

I'm building a U-net for a two-class image segmentation problem using Keras. I'm loosely following the example given here: https://github.com/zhixuhao/unet . Following that example, the last few ...
1
vote
2answers
26 views

Why do we have to import keras from tensorflow if we have already imported tensorflow in python?

I'm now learning tensorflow and keras and I see all tutorials have these two imports: import tensorflow as tf from tensorflow import keras Based on my understanding of python import, I thought the ...
0
votes
0answers
22 views

Customized optimizer in Keras that won't perform update

I am experimenting a new optimizer using Keras. I tried to imitate the code of Adagrad as shown in a previous question; in particular, besides the arguments are different, I have only slightly ...
-1
votes
0answers
12 views

ValueError: bad marshal data (unknown type code), How to solve this problem?

When I run the code, that error message raise. I'm using centos, python 2.7.5, keras 2.2.4 and tensorflow 1.14.0. Somebody said 'remove all .pyc files', but I don't have sudo account, so I can't ...
0
votes
0answers
17 views

tensorflow CTC errors with custom attention layer

I try to build a custom attention with the following code, I have tried to inference the model that i create, and it has the shape and value that I wanted and it works perfectly fine with model....
-1
votes
0answers
8 views

Generalization of RNN/LSTM/GRU… model

Given a time-series prediction with a Recurrent Neural Network (doesn't matter if LSTM/GRU/...), a forecast might look like this: to_predict (orange) was fed to the model, predicted (purple) is the ...
0
votes
0answers
8 views

stacked GRU model in keras

I am willing to create a GRU model of 3 layers where each layer will have 32,16,8 units respectively. The model would take analog calue as input and produce analog value as output. I have written the ...
0
votes
0answers
28 views

Error loading .mat file using scipy.io.loadmat for machine learning

So I've downloaded the vgg19 model from a link provided by a stanford course on coursera (trusted link), the problem is whenever I try to load the model using model = scipy.io.loadmat(filename) it ...
0
votes
0answers
14 views

tensorflow to tflite - tflite_converted fails with “Axis 0 computes to size 0 for StridedSlice” when converting from .pb to .tflite

I'm having an issue when converting from a saved .pb Tensorflow model to a .tflite Tensorflow Lite model using the Tensorflow (1.13.1) built-in tflite_convert tool, and I was wondering how I might go ...
0
votes
0answers
18 views

How do I generate logscale random values between two numbers for hyper-parameter tuning i.e. learning rate?

For hyperparameters like learning rate, generating random numbers between 0.0001 and 1 will not provide an accurate representation of the hyperspace. How would I generate 100 random numbers between 0....
0
votes
1answer
17 views

What is the difference between setting a Keras model trainable vs making each layer trainable

I have a Keras Sequential model consisting of some Dense Layers. I set the trainable property of the whole model to False. But I see that the individual layers have still their trainable property set ...
1
vote
1answer
25 views

Why is my CNN overfitting and how can I fix it?

I am finetuning a 3D-CNN called C3D which was originally trained to classify sports from video clips. I am freezing the convolution (feature extraction) layers and training the fully connected ...
1
vote
0answers
7 views

Distributed Tensorflow error: Check failed: DeviceNameUtils::ParseFullName(new_base, &parsed_name)

Trying to run a distributed tensorflow example on CPU from: https://github.com/tmulc18/Distributed-TensorFlow-Guide/blob/master/Distributed-Setup/dist_setup.py Commands to run the example can be ...
0
votes
0answers
10 views

Keras InvalidArgumentError Error When Specifying Validation Data in 'model.fit'

I am building a Keras LSTM to tackle Kaggle's avocado price dataset. I want to use the validation_data parameter of Keras' model.fit() function. However, when I add that parameter, an ...
-2
votes
1answer
27 views

what if I want to run my Google Colab notebook on more powerful server [on hold]

The free resource provided by the Google Colab isn't enough for my use case. Is there a way to spin more powerful GPU/TPU with more memory and to use it for my Colab notebook in Google Cloud? It ...
0
votes
0answers
8 views

Keras ImageDataGenerator Comparison to Original Image

I'm trying to learn a bit more about how the Keras ImageDataGenerator class works. (https://keras.io/preprocessing/image/) Specifically, I would like to know if it's possible to reference the ...
0
votes
0answers
9 views

How to specify variables in tensorflow simple save

I am trying unsuccessfully to save my tensorflow model using the simple save method. I have built a model using keras and trained it successfully, with an accuracy of 88%. I am now trying to save ...
0
votes
0answers
15 views

Use tf.metrics.mean_per_class_accuracy in Keras

I am trying to find a way of using tf.metrics.mean_per_class_accuracy as Keras metric. My classes are binary and the metric I want to perform is : this one. So it perfectly corresponds to ...
1
vote
0answers
33 views

Input for LSTM using one hot encoding

Time series forecasting: My data contains fo categorical values and to predict the next value. The categorical values are converted into one hot encode values using keras. [[0. 0. 0. ... 0. 0. 0.] [...
0
votes
0answers
24 views

How to custom a loss function with a trainable parameter?

I want to customize the following loss function with a training parameter, where λ is the regularization term and w is a trainable parameter. I custom the loss layer and add the loss into my model. ...
0
votes
0answers
15 views

How to get back model parameters in custom keras callback?

I'm trying to write a custom Keras callback, and I am not able to figure out which parameters of a model layer are available to get their values, (to print or something else). What does this depend on?...
1
vote
0answers
15 views

In case of 2 keras models sharing layers, which model to compile after setting trainable=False?

I have 2 keras models I need to train. Lets say first model has 5 layers. Now I call the last 3 layers of the first model to be another model. Like this: input=Input(shape=(100,)) x1=Dense(50, ...
1
vote
0answers
61 views

Why does MATLAB produce an error when calling a python script with “from tensorflow import keras”?

I have the following python script (test_from_import.py) from tensorflow import keras #import tensorflow.keras from tensorflow.keras import backend as K that I call from MATLAB (R2018a) with the ...
0
votes
0answers
11 views

FailedPreconditionError: Error while reading resource variable module.. while evaluating tensorflow pretrained model

I have trained a binary image classifier through inception3. I am able to evaluate the model immediately after creating it. But if I save the model and reload it and then try to evaluate or predict, ...
2
votes
1answer
31 views

Non-linear loss combination

My network has 2 outputs. I'm trying to have a loss on two terms that is not a linear sum of two losses: def weightedBCE(y_true, y_pred): assert y_pred.shape[2] == 2 y_pred_val = y_pred[:,:,0]...
0
votes
0answers
26 views

How to create a .exe from py file using PyQt5, keras and some external files

i have a py file that using another py file for UI. i am using keras, PyQt5 and pymatbridge packages and some external files like txt csv matlab file. i want to create a one exe file that run my code ...
1
vote
0answers
26 views

Keras and AutoGraph

Reading this and this answer I understood that with non-dynamical models on TensorFlow-2.0, Keras would use AutoGraph. But now writing a callback to get the variables' history during training, class ...
0
votes
0answers
22 views

Keras LSTM fit underfitting

I have time series training data of about 5000 numbers. For each 100 numbers, I am trying to predict the 101st. At the end of the series, I would put in the predicted numbers back into the model to ...
0
votes
1answer
20 views

Why does a Keras model object's predict method not allow batch size of 1?

I've trained a fine-tuned ELMo model using Keras that will only predict with a batch_size of 2. Here's some example code: model_input = np.repeat(np.array([str(user_input)]), 2) model.predict(...
0
votes
1answer
14 views

Where to implement Layer normalization?

I am trying to implement Layer normalization on my LSTM model but I am unsure of how many Layer norms I need in my model and where to exactly place them def build_model(): model = Sequential() ...
0
votes
0answers
6 views

Autoencoder reconstruction artifacts

Iam training a convolutional autoencoder with CT images, where each image consists of 3 channels. The first channel has the CT image in it, the other two consist of segmentation masks. Both training ...
1
vote
0answers
18 views

Adding custom base64-string conversion layer to existing Keras model

I am trying to configure a model that I previously trained to classify images in a such a way that it accepts images as base64-strings (instead of a NumPy array), converts them to a NumPy array and ...
-2
votes
0answers
13 views

Code works well in Spyder but not in Google colab

I am trying to do this Machine Translation problem in python 3.6 . Everything works well when I execute the code in Spyder,but when I try the code in google colab, there are errors. Can anyone help me?...
0
votes
1answer
29 views

Train Neural network with more 2 input features

I already referred to the keras guide on using multiple inputs. However, I am still stumped as I am new to RNNs and CNNs. I am working with keras to train a neural network classifier. In my csv file, ...
0
votes
0answers
26 views

Reuse layer weights from similar net previously trained in Keras

Imagine that my network made in Sequential mode in Keras currently has 3 hidden layers, with [3,5,4] nodes, and I trained it for a given dataset. If now I want to create another network for the same ...
0
votes
1answer
20 views

Keras gives an error when building a dummy model

I am building the tiny yolo cnn model in Keras. I get a strange error. Anyone can help? Imports import numpy as np import matplotlib.pyplot as plt import cv2 import glob #from moviepy.editor import ...
0
votes
0answers
14 views

tensorboard - error:Trace already enabled - How to solve?

I'm trying to learn and use tensorboard and followed these guideline codes with a few modifications. When I run the code model.fit(x=x_train, y=y_train, epochs=5, ...
0
votes
2answers
26 views

Is it a good model in the making with validation loss remaining lower than train curve, more or less constant gap as both are decreasing?

Adding dropout layers made the val loss remain lower than train loss, is it exceptable to have a constant generalization gap over the period? Here is the architecture: tf.keras.layers.CuDNNLSTM(1024,...
1
vote
2answers
28 views

AttributeError: 'module' object has no attribute 'placeholder', How can I resolve this problem?

When I run the code, that error message raise. I'm using python 2.7.5, keras 2.2.4 and tensorflow 2.0.0-beta1. Somebody told me 'don't make file name tensorflow', but I didn't make like that. I think ...
-1
votes
1answer
22 views

training and prediction module API do not run same time using flask

I used Mask_RCNN module with flask When I do not add K.clear_session() then I face this error in training and prediction module error Cannot interpret feed_dict key as Tensor: Tensor Tensor(\"...