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
0
votes
0 answers

How can i define a neural network function and use it later inside a for-loop?

I'm trying to define the neural network model as a function and use it after inside a for-loop. But I'm having different results when defining the model inside the for loop as the following: The first Case: def model_1(): model_1 =…
0
votes
1 answer

CNN binary classification model ValueError: logits and labels must have the same shape ((None, 1) vs (None, None, None, None))

I am receiving a value error when attempting to fit my model to the training set and am unsure how to reshape either my labels or logits to resolve this issue. The code for the model is below, and for reference: train_images.image_shape = (256, 256,…
Paul Song
  • 25
  • 5
0
votes
1 answer

Keras Tensorflow: Why this error on using Tensor Dataset returned by tf.data.experimental.make_csv_dataset() in call to model.fit?

I have training data and validation data in two csv files, each containing a target column. I am trying to load these using a Data API Dataset, and feed to the model.fit() method. I am using Keras 2.8.0 import tensorflow as tf from tensorflow import…
0
votes
0 answers

Training Dataset on a too big dataset (keras) (google Colab)

I'm trying to train a model with the following code in Colab, using keras: model.fit( x_tr, y_tr, batch_size = 1, callbacks=[model_checkpoint_callback], validation_data = (x_val, y_val), epochs = num_training) The…
0
votes
1 answer

How to predict (multi) labeled datapoints?

for example if I have 5 points and each point has dimension of 3 and has one of 10 possible labels from 0 to 9. Points XTrain: [[0.20861965 0.47901568 0.92075312], [0.96175914 0.70659989 0.82364516], [0.51805523 0.42727509 0.92545694],…
MUST_DIE
  • 49
  • 1
  • 11
0
votes
0 answers

Custom Function Keras, Python

I want to estimate F in this equation using a Dense neural network. Y = F(X) @ U. F is a 3x3 matrix, U, X and Y are 3x1 vectors. I create following network, from keras.models import Sequential from keras.layers import Dense from…
mas
  • 1
0
votes
1 answer

constrained optimization, adding an additional term in a custom loss function in a NN

I am struggling to add an additional constraint into my loss function (Keras, tensorflow) My original loss function is: self.__loss_fn = tf.reduce_mean( tf.square( self.__psiNNy - tf.matmul(self.__psiNNx,…
0
votes
1 answer

Supress Tensorflow warnings within jupyter notebook cell in python

I want to remove all warnings from pythons tensorflow==2.8 . I do imports like this import tensorflow from tensorflow.keras.models import Sequential I try the following, but nothing of these methods keep Warnings or Infos out of my results'…
0
votes
1 answer

Data Normalization in Tensorflow Model

I have a Tensorflow regression model that i have with been working with. I have the model tuned well and getting good results while training. However, when i goto evalute the results are horrible. I did some research and found that i am not…
0
votes
1 answer

What to do if I don't want to waste samples by flooring steps_per_epoch in model.fit?

I have a model that has 536 training samples, and would like to run through all the samples per epoch. The batch size is 32, epoch is 50. Here is the code and its error: results = model.fit(train_X, train_y, batch_size = 32, epochs = 50,…
Kay
  • 43
  • 1
  • 7
0
votes
0 answers

How to remove layers in Keras after loaded a keras model (Efficient Net B7)

I load the model in this way: model = EfficientNetB7(weights='imagenet', include_top=False, input_shape=input_shape) What i am trying to do is remove the layer in position: model.layers[1] #Rescaling model.layers[2] #Normalization What i tried…
0
votes
1 answer

How to use tf.keras.utils.image_dataset_from_directory to load test dataset?

I am using tf.keras.utils.image_dataset_from_directory in my binary classification Mobilenet V2 model to split the dataset by defining training and validation subsets as following: train_dataset =…
0
votes
1 answer

How do I add a layer to perform an elementwise product with constants using the Keras API?

I have a simple fully-connected feed-forward neural network built using the Keras API. The network has one input, a single hidden layer with two neurons, and an output of size three. from keras.models import Sequential from keras.layers import…
0
votes
1 answer

How to fix "AttributeError: module 'keras.backend' has no attribute.."

Code: from keras import backend as K K.set_image_dim_ordering('tf') Error: AttributeError: module 'keras.backend' has no attribute 'set_image_dim_ordering'
Veer
  • 1
  • 1
0
votes
1 answer

Add longitude and latitude as features in tensorflow-recommender model

I am making a recommender system. For similar queries I want to give similar recommendations. I was following the example from here: https://www.tensorflow.org/recommenders/examples/featurization?hl=en User creates a query. He can choose the desired…