5,839 questions
0
votes
0
answers
30
views
TensorArray read when size is 0
num_items function throws
in user code:
File "/Users/anu/PycharmProjects/Siglip/KVCache.py", line 12, in num_items *
tf.cond( self.key_cache.size() > 0,
OutOfRangeError: Tried to read ...
0
votes
0
answers
40
views
Why is the wall time from the full trace different from the timer in the compute function?
In my custom operator(runs on cpu), I use butil::Timer to measure the time taken as shown below:
void Compute(OpKernelContext* ctx) override {
butil::Timer total_timer;
total_timer.start();
...
2
votes
0
answers
66
views
Issue Replicating TF-Lite Conv2D Quantized Inference Output
I am trying to reproduce the exact layer-wise output of a quantized EfficientNet model (TFLite model, TensorFlow 2.17) by re-implementing Conv2D, DepthwiseConv2D, FullyConnected, Add, Mul, Sub and ...
1
vote
1
answer
57
views
TensorFlow Custom Training Loop with Mixed Precision Causing NaN Loss After Epoch 15
I am implementing a custom training loop in TensorFlow 2.18 with mixed precision (float16) for a large vision transformer model. The training runs fine for about 15 epochs, but then the loss suddenly ...
0
votes
2
answers
63
views
Tensorflow gradient returns None
I am being implementing a custom layer that returns both the transformed output and an auxiliary loss term. The forward pass works fine, but when I try to compute gradients, I get None for the main ...
0
votes
0
answers
39
views
Tensorflow lite not able to train model on device calling a signature function
I am trying to use tensorflow lite to call a train() signature function in my tflite model. I keep getting this error:
java.lang.IllegalStateException: Model initialization failed. The TensorFlow ...
0
votes
0
answers
52
views
How to replace tf.placeholder in TensorFlow 2.x?
I’m learning TensorFlow 2.x and I have some code from TF 1.x:
X = tf.placeholder(tf.float32, shape=[None, 784])
Y = tf.placeholder(tf.float32, shape=[None, 10])
When I run this in TF 2.x, I get:
...
0
votes
0
answers
38
views
AWS Sagemaker invoke endpoint error "Could not find variable lstm_model/dense/bias"
I have trained a model and deployed as endpoint using aws sagemaker and when I tried to invoke I have got error:
2025-09-09 14:58:25.724914: I external/org_tensorflow/tensorflow/core/framework/...
1
vote
0
answers
36
views
Quantization In Tensorflow2, Instance error
I am trying to quantize a model in tensorflow using tfmot.
This is a sample model,
inputs = keras.layers.Input(shape=(512, 512, 1))
x = keras.layers.Conv2D(3, kernel_size=1, padding='same')(inputs)
x =...
0
votes
1
answer
69
views
TensorFlow Serving significantly slower than Keras model.predict()
I'm deploying a Keras model using TensorFlow Serving, but the inference time is significantly slower compared to calling model.predict() directly in Python.
Running model.predict(input) on a batch of ~...
0
votes
1
answer
27
views
Is there a way to save/restore the graph(s) of a tf.function
I use in my project large graphs that can take more than 5min of compilation time. I decorated the large intermediate parts using a tf.function(reduce_retracing=True). I also heavily use tf....
0
votes
0
answers
49
views
How to resolve AttributeError: 'str' object has no attribute '_type_enum' in tensorflow?
I'm experimenting with gradients of individual losses, but I can't get the gradient of the single loss_PDE loss to run with the unconnected_gradients argument included. It runs if I delete the ...
0
votes
0
answers
47
views
Issue with building a loss in keras model when migrating to tensorflow 2
I am working on implementing Deep Learning model in a "Weakly Supervised manner" based on this model (FEAWAD.py).
As it was developed under Tensorflow 1, I first have to migrate it to ...
0
votes
0
answers
101
views
Tensorflow allocates memory on GPU but GPU utilization 0% when running keras.model.fit()?
I am training a CNN using keras and tensorflow on my NVIDIA RTX 2000 Ada Generation Laptop GPU on Ubuntu 24.04 with recommended nvidia-driver-570.
When I train my network on the cpu only version of ...
0
votes
0
answers
45
views
Tensorflow: XLA compilation requires a fixed tensor list size
I'm running Ubuntu on a laptop with a dGPU.
I installed tensorflow using docker: docker pull tensorflow/tensorflow:latest.
Tensorflow (2.19.0) can use a XLA CPU and a GPU.
I'm following this tutorial: ...
0
votes
0
answers
18
views
how to use LimeTabularExplainer when the shape of both my training data and test data is 3D tensor in tensorflow?
I am using tensorflow.
I have got a tensor X_train_tensor with share (16462, 60, 33)
When I use LIME
explainer = lime_tabular.LimeTabularExplainer(X_train_sequence_tensor, mode = "regression"...
0
votes
1
answer
68
views
Why does TimeDistributed(Flatten()) raise an InvalidArgumentError when reshaping works?
I'm building a lip-reading model using tensorflow.keras and getting an error when applying TimeDistributed(Flatten()) after my Conv3D layers. Here's a simplified version of my model architecture:
CODE
...
-1
votes
1
answer
94
views
'TypeError: Bases must be types' when trying to import tensorflow
When trying to import tensorflow I get the following error:
File "E:/Users/jan/Python_Lernen/NN play_data.py", line 2, in <module>
import tensorflow as tf
File "E:\Users\...
1
vote
0
answers
54
views
PyTorch runtime error with input when using two models
I have two models. One is pretrained with YOLOv11 and detects faces and second one trained from scratch with Tensorflow converted to onnx using tf2onnx and then to pt using onnx2pytorch. Second model ...
0
votes
1
answer
65
views
Why won't tf.keras let me pass a dictionary of multiple sample weights?
I am trying to pass individual np.arrays of sample_weights for two outputs of my Keras model, one of which is a confidence measure of a binary value and one of which is a continuous output. However, I ...
0
votes
1
answer
26
views
Unable to save tensorflow ConvNeXtTiny model in .tf format (TF 2.13.0)
I trained a tensorflow ConvNeXtTiny model (tf.keras.applications.convnext.ConvNeXtTiny). I am able to train the model without any issues. But when I try to save the model with model.save(my_model, ...
0
votes
1
answer
58
views
InvalidArgumentError with tf.data.Dataset.from_generator() at random points during training
I want to use a python generator with a tf Dataset to extract and preprocess sequences from a (rather large) numpy array, but I keep getting this error at random points during the first epoch of ...
0
votes
1
answer
33
views
Stream data to a model form tensorflow datasets without having it to download locally
I was trying to load the dataset from tensorflow datasets without having it to download locally and process it to a pipeline in batches so i can feed it into my model. I'm not sure if I'm doing it ...
1
vote
1
answer
37
views
What is the purpose of `to_list()` function on TensorFlow's TesnorShape objects
I came across a commit that includes to_list() to convert a tensor shape to a list in an assertion as the right-hand operand was a list. I wanted to understand the reason for using this function, so ...
1
vote
0
answers
118
views
Tflite Detection Postprocess Explanation
I am trying to replicate the working of TFLITE_DETECTION_POSTPROCESS layer for a custom object detection model.
Does anyone has any reference for TFLITE_DETECTION_POSTPROCESS layer implementation in ...
0
votes
0
answers
18
views
tensorboard of tensorflow-gpu docker image does not work on browser
I have a tensorflow-gpu installation using docker to use my gpu cuda capabilities.
I run my code inside a wsl session in vscode.
After running !tensorboard --logdir="tensorboard-graphs/" --...
0
votes
1
answer
135
views
How to save checkpoint in tensorflow format in ver 2.18?
There was a feature - tensorflow format to save a checkpoint. I have checked and it is everywhere in the official docs and samples: https://www.tensorflow.org/tutorials/keras/save_and_load#...
0
votes
1
answer
59
views
InaccessibleTensorError when using multiple TensorArrays in a list
I am implementing a fairly complex network structure where I need to loop over a (possibly variable) time dimension, compute values at each step, and collect all these values, and do this for multiple ...
1
vote
1
answer
37
views
Saved tensorflow model makes wrong predictions
I have trained a regression model with tensorflow and I got very good results on my test dataset. I saved this model with model.save(), but when I tried to load it with tf.keras.models.load_model(&...
0
votes
1
answer
384
views
Using SavedModel format in Keras 3.5
I came up against a problem when trying to use tf.keras.models.load_model(Path_to_pb_model) to load a Savedformat model.
I'm using Tensorflow 2.17.1 with Keras 3.5.
Apparently Keras 3 only accepts ....
1
vote
1
answer
88
views
Does keras/TF support non-time-step masking?
Masking is a very broad term which normally means ignore part of.
However, the docs on masking describe it as:
Masking is a way to tell sequence-processing layers that certain timesteps in an input ...
2
votes
1
answer
63
views
Tensorflow Probability MixtureNormal layer example not working as in example
Tensorflow version is 2.17.1
Tensoflow probability version is 0.24.0
Example from the documentation https://www.tensorflow.org/probability/api_docs/python/tfp/layers/MixtureNormal?hl=en is the ...
0
votes
0
answers
32
views
Unequal width and height of stride in tf.nn.depthwise_conv2d not supported?
Is that right?
IF YES, how can I convert the pretrained weights trained with unequal strides to tensorflow dw-conv with some other ops?
THX
1
vote
2
answers
86
views
tensorflow.keras only runs correctly once
I am using tensorflow.keras in a jupyter notebook to produce a neural network to match some real world data. The first time I run my code, it works correctly. The neural network gives a model to match ...
0
votes
0
answers
15
views
Clarification on security patches and test coverage in TensorFlow contributions
In the contribution guidelines, it is clearly mentioned that "All new features and bug fixes must include adequate test coverage." However, I’ve noticed that most security patches seem to ...
1
vote
1
answer
50
views
Graph disconnected error when loading model in Tensorflow
I am running a code repository and I got an error message while recreate the model.
ValueError: Graph disconnected: cannot obtain value for tensor KerasTensor(type_spec=TensorSpec(shape=(None, 32, 32,...
0
votes
0
answers
74
views
How to resolved the import error with scipy when using keras_tuner?
I have download the tensorflow nightly version 2.19.0.dev20241219 (cpu version) and download the version keras_tuner 1.4.7 and keras 3.7.0. I also check my system has the scipy version 1.15.0. ...
0
votes
0
answers
74
views
Invalid input shape for input Tensor("sequential_1/Cast:0", shape=(None, 30), dtype=float32)
I wrote:
from __future__ import absolute_import, division, print_function, unicode_literals
import numpy as np
import tensorflow as tf
from keras.models import Sequential
from keras.layers import ...
1
vote
1
answer
466
views
ValueError: Exception encountered when calling layer 'tf_bert_model' (type TFBertModel)
I have been trying to run TFBertModel from Transformers, but it kept on throwing me this error
ValueError Traceback (most recent call last)
Cell In[9], line 1
----> 1 ...
0
votes
0
answers
44
views
Using 'from_tensor_slices' causes the model to stop learning
I am trying to train a simple CNN on custom image data. While training with raw numpy data, the model learns as expected. However when I convert the same raw numpy data to dataset using tf.data....
0
votes
0
answers
27
views
tensorflow gradient of py_function containing numpy function
I created a py_function to wrap the numpy interp function. But when I take the gradient, it returns a single number, when it should be a vector of length 10. What's going on? I don't know know to ...
0
votes
1
answer
31
views
using tensorflow gather for 3D tensors
I have a 3D tensor called V, with shape (P,Q,R) and a 2D tensor called W with shape (P,S).
I want to create a tensor Z of shape (P,Q,R) where Z[i,j,k] = W[i,V[i,j,k]]. In other words, each row of W ...
0
votes
0
answers
484
views
Appropriate GPU deepface
I am currently using only CPU(intel-13700K) for deepface to run face recognition.
I have achieved 15 images per second on my dataset; however, striving for more.
I am using a combination of ArcFace + ...
0
votes
0
answers
218
views
FileNotFoundError: [Errno 2] No such file or directory: 'patchelf' while building TensorFlow from source
Description:
I am trying to build TensorFlow 2.18 from source on CentOS 8 with the following environment:
Python Version: 3.10,
Bazel Version: 6.5.0,
CUDA/cuDNN Version: CUDA 12.5 / cuDNN 9.3,
GCC/...
0
votes
1
answer
730
views
Problem with tensorflow non linearity Apple M4 Chips
I have a problem with the result of non-linear(sigmoid) Neural Network Classification in tensorflow. I suspect is a problem with the M chip and my instalation but I tried several versions using ...
0
votes
1
answer
16
views
Keras metrics are aggregated over training?
Most TF keras models I see are implemented where at the end of a training step they calculate some metric and use metric.update_state(metric_value) to log the metric.
As far as I can understand this ...
1
vote
0
answers
84
views
InvalidArgumentError, Deep Learning with Python, Example 10.2.3
I'm trying example 10.2.3 from the book Deep Learning with Python by François Chollet. I'm getting an error on the line history = model.fit(...) using Tensorflow 2.17. However, I don't get an error if ...
1
vote
0
answers
27
views
How can I get model summary from a Object Detection API model?
I am working with https://github.com/tensorflow/models/tree/master/research/object_detection, where I have loaded the following model using pipeline config:
import tensorflow as tf
from ...
1
vote
1
answer
412
views
TensorFlow 2.14.0 Fails to Detect GPU on Google Colab
I'm trying to use Mask-RCNN with a GPU on Google Colab, as I need a powerful GPU that my local machine lacks. I’ve even subscribed to Google Colab Pro for this purpose. I've implemented a repository ...
1
vote
0
answers
82
views
Tensorflow serving keras bert model issue
I am trying to use tensorflow serving to serve a keras bert model, but I have problem to predict with rest api, below are informations. Can you please help me to resolve this problem.
predict output (...