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
9
votes
5 answers

How to save/restore large model in tensorflow 2.0 w/ keras?

I have a large custom model made with the new tensorflow 2.0 and mixing keras and tensorflow. I want to save it (architecture and weights). Exact command to reproduce: import tensorflow as tf OUTPUT_CHANNELS = 3 def downsample(filters, size,…
Ridane
  • 101
  • 1
  • 7
9
votes
1 answer

How does Tensorflow calculate the accuracy of model?

I am following this tutorial for binary class classification. While defining the model it is defined as follows and quotes: Apply a tf.keras.layers.Dense layer to convert these features into a single prediction per image. You don't need an…
Gambitier
  • 504
  • 6
  • 18
9
votes
1 answer

keras fit_generator: 'zip' object has no attribute 'shape'

as in keras documentation in the (image, mask) data generator, I created data generator to have (input, output) tuple images. When running locally on my laptop (with tensorflow 1.13.1), it runs with no issues, but when running on a server (with…
Yael N
  • 111
  • 2
  • 8
8
votes
1 answer

Can SigmoidFocalCrossEntropy in Tensorflow (tf-addons) be used in Multiclass Classification? ( What is the right way)?

Focal Loss given in Tensorflow is used for class imbalance. For Binary class classification, there are a lots of codes available but for Multiclass classification, a very little help is there. I ran the code with One Hot Encoded target variables of…
Deshwal
  • 3,436
  • 4
  • 35
  • 94
8
votes
3 answers

Cannot use keras models on Mac M1 with BigSur

I am trying to use Sequential model from keras of tensorflow. When I am executing following statement: model.fit(x_train, y_train, epochs=20, verbose=True, validation_data=(x_dev, y_dev), batch_size=10) I am getting following errors: I…
Ankita
  • 159
  • 1
  • 3
  • 10
8
votes
4 answers

Keras - no good way to stop and resume training?

After a lot of research, it seems like there is no good way to properly stop and resume training using a Tensorflow 2 / Keras model. This is true whether you are using model.fit() or using a custom training loop. There seem to be 2 supported ways to…
Daniel
  • 1,125
  • 2
  • 9
  • 21
8
votes
1 answer

TF2.1: SegNet model architecture problem. Bug with metric calculation, keeps constant and converge to determined value

I'm building a custom model (SegNet) in Tensorflow 2.1.0. The first problem I'm facing is the reutilization of the indices of the max pooling operation needed as described in the paper. Basically, since it is an encoder-decoder architecture, the…
rpasianotto
  • 1,383
  • 1
  • 9
  • 22
8
votes
0 answers

Call Model.fit with tensors / Executing op on CPU not GPU / Tensorflow 2.1

I am experimenting with reinforcement learning in python. I am using Tensorflow 2.1 and my machine has muyliple GPUs (with CUDA 10.2 driver 440.59). I am allocating the operations on my GPUs using tf.device(). I am not using the…
NicMaq
  • 81
  • 3
8
votes
2 answers

Does tf.keras.metrics.AUC work on multi-class problems?

I have a multi-class classification problem and I want to measure AUC on training and test data. tf.keras has implemented AUC metric (tf.keras.metrics.AUC), but I'm not be able to see whether this metric could safely be used in multi-class problems.…
8
votes
1 answer

Dictionary of tensors input for Keras Functional API TensorFlow 2.0

I have a dataset of dictionary of tensors, and the following model defined using the subclassing API: class Model(tf.keras.Model): def __init__(self): super().__init__() self._movie_full_dense = tf.keras.layers.Dense( units=40,…
8
votes
1 answer

Saving and loading multiple models with the same graph in TensorFlow Functional API

In the TensorFlow Functional API guide, there's an example shown where multiple models are created using the same graph of layers.…
mpotma
  • 243
  • 1
  • 9
8
votes
5 answers

How do I calculate the matthews correlation coefficient in tensorflow

So I made a model with tensorflow keras and it seems to work ok. However, my supervisor said it would be useful to calculate the Matthews correlation coefficient, as well as the accuracy and loss it already calculates. my model is very similar to…
Toby Peterken
  • 183
  • 1
  • 3
8
votes
1 answer

Tensorflow model.fit() using a Dataset generator

I am using the Dataset API to generate training data and sort it into batches for a NN. Here is a minimum working example of my code: import tensorflow as tf import numpy as np import random def my_generator(): while True: x =…
berkelem
  • 2,005
  • 3
  • 18
  • 36
8
votes
1 answer

AttributeError: The layer has never been called and thus has no defined input shape

I'm tring to build an autoencoder in TensorFlow 2.0 by creating three classes: Encoder, Decoder and AutoEncoder. Since I don't want to manually set input shapes I'm trying to infer the output shape of the decoder from the encoder's…
Ivan Lorusso
  • 145
  • 1
  • 2
  • 9
8
votes
1 answer

Should I use the standalone Keras library or tf.keras?

As Keras becomes an API for TensorFlow, there are lots of old versions of Keras code, such as https://github.com/keiserlab/keras-neural-graph-fingerprint/blob/master/examples.py from keras import models With the current version of TensorFlow, do we…
jason
  • 1,998
  • 3
  • 22
  • 42