Skip to main content

All Questions

Tagged with
0 votes
1 answer
63 views

Why do model.evaluate() vs. manual loss computation with model.predict() in tf.keras do not add up?

I use keras and tensorflow to train a 'simple' Multilayer Perceptron (MLP) for a regression task, where I use the mean-squared error (MSE) as loss-function. I denote my training data as x_train, ...
Red's user avatar
  • 113
1 vote
1 answer
91 views

numpy eager execution problem after loading a CNN model

I want to save and load a CNN model to further training. I have developed a model and saved it as .h5 file. There is no problem when creating, training, and saving at first run. The problem exists ...
Arief Kurniawan's user avatar
0 votes
1 answer
113 views

Training a Keras model to identify leap years

I'm trying to teach my learning model how to identify leap years. My Python code can be seen below: import tensorflow as tf import numpy as np import calendar # ------------------- UTILITY FUNCTIONS -...
Ricardo DS's user avatar
4 votes
1 answer
46 views

keras model does not learn if using tf.data pipeline

A keras model does learn using Numpy arrays as the input, but fails to make any progress if reading data from a tf.data pipeline. What could be the reason potentially? In particular, the model ...
Dmitry Zotikov's user avatar
0 votes
1 answer
43 views

How to apply a threshold filter to a layer?

Having an array like this : input = np.array([[0.04, -0.8, -1.2, 1.3, 0.85, 0.09, -0.08, 0.2]]) I want to change all the values (of the last dimension) between -0.1 and 0.1 to zero and change the ...
Nassim MOUALEK's user avatar
0 votes
0 answers
111 views

I need to convert a symbolic Keras tensor into a NumPy array to pass it via PyBind11 to a C++ lib

I use Python 3.12.3, NumPy 1.26.4, TensorFlow 2.17.0 - this one without GPU support. According to some research, these are compatible. I've installed them in a private environment in my home directory....
Balázs Bámer's user avatar
0 votes
1 answer
53 views

What is the difference between Dropout(1.0) and stop_gradient?

Consider these two architectures: prev_layer -> dropout 1.0 -> next_layer (output layer) prev_layer -> stop_gradient -> next_layer (output layer) As gradients flow from the output layer ...
Citra Dewi's user avatar
0 votes
1 answer
46 views

How do I pass sklearns train_test_split actual dataseries and not single values as input argument?

I want to train an LSTM-based RNN model for binary classification and for that I wanted to use tensorflow keras model with LSTM layers. In order to do so, I need testing input and output as well as ...
actopozipc's user avatar
0 votes
1 answer
53 views

TensorFlow - InvalidArgumentError: Shapes of all inputs must match

I am currently following the TensorFlow guide/tutorial on seq2seq NMT models (https://www.tensorflow.org/text/tutorials/nmt_with_attention) using a Jupyter Notebook. Upon running the following code, # ...
CauseYNot's user avatar
  • 1,338
0 votes
1 answer
42 views

Preventing weights update for certain samples in Keras3

I have a custom layer called ControlledBackward that accepts prev_layer and input_layer_of_mask: class ControlledBackward(Layer): def __init__(self, **kwargs): super(ControlledBackward, self)....
Citra Dewi's user avatar
3 votes
1 answer
1k views

Hashed cross-product transformation in PyTorch

I want to implement a hashed cross product transformation like the one Keras uses: >>> layer = keras.layers.HashedCrossing(num_bins=5, output_mode='one_hot') >>> feat1 = np.array([1, ...
David Davó's user avatar
0 votes
1 answer
41 views

arr_to_image changes the grayscale images

When processing images, I encountered strange behavior when converting a PIL gray image to a NumPy array. Here is a small code that loads a gray image image. from keras.utils import img_to_array, ...
vrs's user avatar
  • 1
0 votes
0 answers
29 views

Reshaping spatiotemporal dimension of mmap numpy so that it can be fed to ConvLSTM2D

I have this tensor of multidimensional array: # read from memory-mapped files # File paths for memory-mapped files input_file_path = 'tensor_input.dat' output_file_path = 'tensor_output.dat' # ...
Muhammad Ikhwan Perwira's user avatar
0 votes
0 answers
756 views

Getting Error "object __array__ method not producing an array" while training a model

I am trying to train a model using the neural network model Sequential. Every thing is going good till the model compilation. As soon as i hit model.fit() for model training i get the error "...
Manthan Sharma's user avatar
1 vote
1 answer
41 views

Broadcasting multiple versions of X_data that pair with the same y_data

My deep learning architecture accepts an input vector with size 512 and an output vector with size 512 too. The problem is I have X_data version that pairs with the same y_data. I have these tensors: (...
Muhammad Ikhwan Perwira's user avatar

15 30 50 per page
1
2 3 4 5
74