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
10
votes
1 answer

Is it meaningless to use ReduceLROnPlateau with Adam optimizer?

This question is basically for the working of Keras or tf.keras for people who have the verty deep knowledge of the framework According to my knowledge, tf.keras.optimizers.Adam is an optimizer which has already an Adaptive Learning rate scheme. So…
Deshwal
  • 3,436
  • 4
  • 35
  • 94
10
votes
1 answer

ImportError: cannot import name 'keras_tensor' from 'tensorflow.python.keras.engine'

I'm getting this error while loading the tensorflow addons library import tensorflow_addons as tfa ImportError: cannot import name 'keras_tensor' from 'tensorflow.python.keras.engine'
dpacman
  • 3,683
  • 2
  • 20
  • 35
10
votes
5 answers

TypeError: Tensor is unhashable. Instead, use tensor.ref() as the key. in Keras Surgeon

I'm using Kerassurgeon module for pruning.I encountered this error while i'm working with VGG-16 in google colab.It works fine for other models.Can someone help me fix this. ---> 17 model_new = surgeon.operate()
18 return…
Nikhil Dupally
  • 753
  • 1
  • 4
  • 12
10
votes
1 answer

How to save a list of numpy arrays into a single file and load file back to original form

I am currently trying to save a list of numpy arrays into a single file, an example of such a list can be of the form below import numpy as np np_list = [] for i in range(10): if i % 2 == 0: np_list.append(np.random.randn(64)) else: …
DVK
  • 475
  • 2
  • 6
  • 27
10
votes
1 answer

CUDNN_STATUS_BAD_PARAM when trying to perform inference on a LSTM Seq2Seq with masked inputs

I'm using keras layers on tensorflow 2.0 to build a simple LSTM-based Seq2Seq model for text generation. versions I'm using: Python 3.6.9, Tensorflow 2.0.0, CUDA 10.0, CUDNN 7.6.1, Nvidia driver version 410.78. I'm aware of the criteria needed by…
Felipe
  • 11,557
  • 7
  • 56
  • 103
10
votes
2 answers

Passing `training=true` when using Tensorflow 2's Keras Functional API

When operating in graph mode in TF1, I believe I needed to wire up training=True and training=False via feeddicts when I was using the functional-style API. What is the proper way to do this in TF2? I believe this is automatically handled when using…
cosentiyes
  • 364
  • 2
  • 16
10
votes
1 answer

Tensorflow 2.0: Accessing a batch's tensors from a callback

I'm using Tensorflow 2.0 and trying to write a tf.keras.callbacks.Callback that reads both the inputs and outputs of my model for the batch. I expected to be able to override on_batch_end and access model.inputs and model.outputs but they are not…
francoisr
  • 4,407
  • 1
  • 28
  • 48
10
votes
2 answers

How do you apply layer normalization in an RNN using tf.keras?

I would like to apply layer normalization to a recurrent neural network using tf.keras. In TensorFlow 2.0, there is a LayerNormalization class in tf.layers.experimental, but it's unclear how to use it within a recurrent layer like LSTM, at each time…
MiniQuark
  • 46,633
  • 36
  • 147
  • 183
9
votes
1 answer

How to use sample weights with tensorflow datasets?

I have been training a unet model for multiclass semantic segmentation in python using Tensorflow and Tensorflow Datasets. I've noticed that one of my classes seems to be underrepresented in training. After doing some research, I found out about…
9
votes
2 answers

Is it still necessary to implement `compute_output_shape()` when defining a custom tf.keras Layer?

I have implemented a custom Layer in tf.keras, using TensorFlow 2.1.0. In the past, when using the stand-alone Keras, it was important to define the compute_output_shape(input_shape) method in any custom layer so that the computational graph could…
Daniele Grattarola
  • 1,517
  • 17
  • 25
9
votes
3 answers

Saving meta data/information in Keras model

Is it possible to save meta data/meta information in Keras model? My goal is to save input pre-processing parameters, train/test set used, class label maps etc. which I can use while loading model again. I went through Keras documentation and did…
Vivek Mehta
  • 2,612
  • 2
  • 18
  • 30
9
votes
1 answer

Use TensorBoard with Keras Tuner

I ran into an apparent circular dependency trying to use log data for TensorBoard during a hyper-parameter search done with Keras Tuner, for a model built with TF2. The typical setup for the latter needs to set up the Tensorboard callback in the…
wishihadabettername
  • 14,231
  • 21
  • 68
  • 85
9
votes
1 answer

Tensorflow: Modern way to load large data

I want to train a convolutional neural network (using tf.keras from Tensorflow version 1.13) using numpy arrays as input data. The training data (which I currently store in a single >30GB '.npz' file) does not fit in RAM all at once. What is the…
Adomas Baliuka
  • 1,384
  • 2
  • 14
  • 29
9
votes
4 answers

In TensorFlow 2.0 with eager-execution, how to compute the gradients of a network output wrt a specific layer?

I have a network made with InceptionNet, and for an input sample bx, I want to compute the gradients of the model output w.r.t. the hidden layer. I have the following code: bx = tf.reshape(x_batch[0, :, :, :], (1, 299, 299, 3)) with…
Vahid Mirjalili
  • 6,211
  • 15
  • 57
  • 80