Questions tagged [tf.keras]

[tf.keras] is TensorFlow's implementation of the Keras API specification. Use the tag for questions specific to this TensorFlow module. You might also add the tag [keras] to your question since it has the same API.

is TensorFlow's implementation of the Keras API specification. Use the tag for questions specific to this TensorFlow module. You might also add the -tag to your question since it has the same API.

gives you the power and flexibility of Keras within TensorFlow (see the docs for examples). The API of is described here.

References:

2208 questions
7
votes
6 answers

pipenv - Pipfile.lock is not being generated due to the 'Could not find a version that matches keras-nightly~=2.5.0.dev' error

As the title clearly describes the issue I've been experiencing, no Pipfile.lock is being generated as I get the following error when I execute the recommended command pipenv lock --clear: ERROR: ERROR: Could not find a version that matches…
talha06
  • 6,206
  • 21
  • 92
  • 147
7
votes
1 answer

SHAP DeepExplainer with TensorFlow 2.4+ error

I'm trying to compute shap values using DeepExplainer, but I get the following error: keras is no longer supported, please use tf.keras instead Even though i'm using tf.keras? KeyError Traceback (most recent call last) in 6 # ...or pass…
Fred
  • 85
  • 1
  • 5
7
votes
1 answer

Do the number of units in a layer need to be defined within a conditional scope when using keras tuner to setup a model?

According to the Keras Tuner examples here and here, if you want to define the number of layers and each layer's units in a deep learning model using hyper parameters you do something like this: for i in range(hp.Int('num_layers', 1, 10)): …
Joe
  • 418
  • 4
  • 12
7
votes
3 answers

Keras Model AttributeError: 'str' object has no attribute 'call'

I'm trying to convert my Keras hdf5 file into a TensorFlow Lite file with the following code: import tensorflow as tf # Convert the model. converter = tf.lite.TFLiteConverter.from_keras_model("/content/best_model_11class.hdf5") tflite_model =…
Bert Hanz
  • 417
  • 1
  • 7
  • 16
7
votes
1 answer

Tensorflow Keras RMSE metric returns different results than my own built RMSE loss function

This is a regression problem My custom RMSE loss: def root_mean_squared_error_loss(y_true, y_pred): return tf.keras.backend.sqrt(tf.keras.losses.MSE(y_true, y_pred)) Training code sample, where create_model returns a dense fully connected…
ma7555
  • 362
  • 5
  • 17
7
votes
1 answer

ValueError: No gradients provided for any variable - Tensorflow 2.0/Keras

I am trying to implement a simple sequence-to-sequence model using Keras. However, I keep seeing the following ValueError: ValueError: No gradients provided for any variable: ['simple_model/time_distributed/kernel:0',…
Stefan Falk
  • 23,898
  • 50
  • 191
  • 378
7
votes
3 answers

Using tf.keras.utils.Sequence with model.fit_generator with use_multiprocessing=True generated warning

This is the warning I got: WARNING:tensorflow:multiprocessing can interact badly with TensorFlow, causing nondeterministic deadlocks. For high performance data pipelines tf.data is recommended. The Sequence subclass I wrote strictly perform load…
kawingkelvin
  • 3,649
  • 2
  • 30
  • 50
7
votes
2 answers

How to correctly use the Tensorflow MeanIOU metric?

I want to use the MeanIoU metric in keras (doc link). But I don't really understand how it could be integrated with the keras api. In the example, the prediction and the ground truth are given as binary values but with keras we should get…
opetit
  • 71
  • 1
  • 3
7
votes
2 answers

In Keras, is there any function similar to the zero_grad() in Pytorch?

In Pytorch, we can call zero_grad() to clear the gradients. In Keras, do we have a similar function so that we can achieve the same thing? For example, I want to accumulate gradients among some batches.
Zijun Xue
  • 71
  • 5
7
votes
1 answer

What is the difference between input_shape and input_dim in keras?

Currently i am learning deep learning and stumbled upon these confusion: when to use input_shape and input_dim parameter. shape of my data is (798,9) and these has 8 input variable and 1 output variable so my question is when making a sequential…
MEET SHAH
  • 93
  • 1
  • 7
7
votes
2 answers

Weighting samples in multiclass image segmentation using keras

I am using a Unet based model to perform image segmentation on a biomedical image. Each image is 224x224 and I have four classes including the background class. Each mask is sized as (224x224x4) and so my generator creates batches of numpy arrays…
7
votes
2 answers

Decay parameter of Adam optimizer in Keras

I think that Adam optimizer is designed such that it automtically adjusts the learning rate. But there is an option to explicitly mention the decay in the Adam parameter options in Keras. I want to clarify the effect of decay on Adam optimizer in…
Arjun
  • 107
  • 1
  • 1
  • 6
7
votes
1 answer

How to fit and evaluate tf.data.dataset with tf.keras at the end of every epoch?

When x is tf.data dataset, a tuple of (inputs, targets) and inputs is a dict of features like {"fea_1": val_1, "fea_2": val_2…}, model.fit function in tensorflow/python/keras/engine/training.py doesn't support validation_data or…
twostarxx
  • 81
  • 1
  • 4
7
votes
1 answer

Redundancies in tf.keras.backend and tensorflow libraries

I have been working in TensorFlow for about a year now, and I am transitioning from TF 1.x to TF 2.0, and I am looking for some guidance on how to use the tf.keras.backend library in TF 2.0. I understand that the transition to TF 2.0 is supposed to…
mickey
  • 476
  • 5
  • 18
7
votes
2 answers

TensorFlow 2.0 How to get trainable variables from tf.keras.layers layers, like Conv2D or Dense

I have been trying to get the trainable variables from my layers and can't figure out a way to make it work. So here is what I have tried: I have tried accessing the kernel and bias attribute of the Dense or Conv2D object directly, but to no avail.…
MattSt
  • 1,024
  • 2
  • 16
  • 35