82,225 questions
3
votes
1
answer
24
views
How to fix ValueError: Only instances of keras.Layer can be added to a Sequential model when adding tensorflow_hub.KerasLayer?
I am learning TensorFlow and transfer learning, and I am trying to add a TensorFlow Hub feature extractor to a Keras Sequential model. But I get this error:
ValueError: Only instances of keras.Layer ...
1
vote
0
answers
34
views
TPU Initialization Fails (OpKernel Missing) Despite Active TPU Runtime in Kaggle
I am facing a persistent issue when trying to initialize the TPU in my notebook. I have already confirmed that:
My account is Verified.
The Notebook Accelerator is set to TPU.
My TPU quota is ...
2
votes
0
answers
46
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 ...
0
votes
1
answer
87
views
PyInstaller - It does'nt generate an .exe file
I'm using pyinstaller main.spec command. The main.spec file is the next:
# -*- mode: python ; coding: utf-8 -*-
a = Analysis(
['main.py', 'flujo.py', 'flujo_if.py', 'descarga_manual.py', '...
0
votes
1
answer
156
views
Why does TFLite INT8 quantization decompose BatchMatMul (from Einsum) into many FullyConnected layers?
I’m debugging a model conversion using onnx2tf and post-training quantization issue involving Einsum, BatchMatMul, and FullyConnected layers across different model formats.
Pipeline:
ONNX → TF ...
3
votes
1
answer
60
views
Unable to import_model .h5 in an attemp to try classification because of "BatchNormalization could not be deserialized properly"
I've got a very small python script using a Model.h5 which should be loaded in order to classify some pictures.
Here's my python script :
import tensorflow as tf
from os import walk
from keras.models ...
Tooling
1
vote
2
replies
49
views
Is using TRT in Tensorflow 2.18+ possible?
I am aware that TensorFlow has announced that they will no longer support TRT. A while back the announced "Starting with TensorFlow 2.18, support for TensorRT will be dropped. TensorFlow 2.17 ...
0
votes
1
answer
47
views
How is cosine-similarity loss working together with a masking layer? Visualisation
I have batches containing windows containing embeddings/vectors. To keep it simple let's not assume sentence embeddings (actual case) but 1hot encoded vectors. They are padded. So in the example below ...
5
votes
1
answer
158
views
Implementing a LoRA wrapper for Conv2D in Tensorflow
I have recently been trying to port a LoRA for CNN method originally implemented in PyTorch to TensorFlow, but my implementation did not work well, and I require assistance in making it work.
My code ...
2
votes
0
answers
41
views
what is the purpose of training=True argument? Is it an argument of keras.sequential() or not? [duplicate]
What is the purpose of training=True argument in the last line. I called help(tf.keras.Sequential) but could not find anything related to it. Also is it the argument of tf.keras.Sequential() or not
...
2
votes
0
answers
90
views
ImportError: cannot import name 'model_lib_v2' from 'object_detection'
I'm attempting to train a model on TensorFlow, and I've used Nick's video as reference:
https://youtu.be/yqkISICHH-U?si=IYW6Jsqhs0gCwMyc&t=8267
I've experienced following error:
Traceback (most ...
1
vote
1
answer
49
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
1
answer
255
views
TensorFlow not detecting NVIDIA GPU (RTX 3050, CUDA 12.7, TF 2.20.0) [duplicate]
I’ve been trying to get TensorFlow to use my GPU on Windows, and even though everything seems installed correctly, it shows 0 available GPUs.
System setup
Windows 11
RTX 3050 Laptop GPU
NVIDIA driver ...
-1
votes
1
answer
41
views
Pretrained ESRGAN (.pb) gives reddish or purple image — is this a preprocessing issue or model issue?
I'm trying to use a pretrained ESRGAN model that I downloaded in .pb format.
The model runs without errors, but the output image has a noticeable reddish/purple tint instead of the correct colors.
...
1
vote
1
answer
300
views
Play Console warning: “Library that does not support 16 KB: base/lib/x86_64/libtensorflowlite_jni.so” when uploading AAB with TensorFlow Lite
I’m uploading my Android App Bundle (AAB) to Google Play Console and getting this warning:
Library that does not support 16 KB:
base/lib/x86_64/libtensorflowlite_jni.so after upgrading the lib
...
0
votes
0
answers
66
views
Streamlit app throwing "NotFittedError: idf vector is not fitted" even though TF-IDF pipeline is fitted and works locally
I trained a sentiment classification model using a scikit-learn Pipeline that includes a TfidfVectorizer and LogisticRegression classifier.
Everything works perfectly on my local machine, but when I ...
1
vote
0
answers
49
views
Can I convert .keras model to .h5 so that tensorflow 2.10 can use it for prediction?
I trained a keras sequential model while working in colab. Now I shifted to a PC with Windows 11. jupyter notebook with Tensorflow 2.10 is unable to read that model. it needs a model in the old .h5 ...
1
vote
0
answers
81
views
TensorFlow 2.18.0 (conda-forge) fails on macOS with down_cast assertion in casts.h
For several months, I have encountered this issue but postponed a thorough investigation due to the complexity introduced by multiple intervening layers, such as Positron, Quarto, and Conda.
Recently, ...
1
vote
0
answers
106
views
Unable to load an hdf5 model file in TensorFlow / Keras
I was given an hdf5 model file that was build with tensorflow / keras. Training data is no more available.
Note: all Python code snippets shown hereunder are run against Python 3.9.23 inside a ...
2
votes
1
answer
123
views
Keras Model throwing Error while integrating with frontend
I trained a model on Colab for my final year project EfficientNetB0. After all the layer training, I tested it and its result was excellent, but now I want to integrate the model to the frontend web ...
1
vote
1
answer
67
views
Mask image in tensorflow
Can I use keras.Layers to build custom layer to mask to whole dataset and return masked dataset. That is
class AttnMask(Layer):
def __init__(self, img_size, attention_map):
super()....
-3
votes
1
answer
95
views
Can I visualize a neural network’s loss landscape to see if it’s stuck in a bad minimum? Any code example for this? [closed]
So, I’m trying to understand why sometimes neural networks get stuck during training. I heard people talk about ‘local minima’ and ‘saddle points,’ but I can’t really picture them. I want to actually ...
1
vote
0
answers
68
views
How do I convert TensorFlow SavedModel into TensorFlow.js format?
I’m trying to convert my TensorFlow SavedModel into a TensorFlow.js format using tensorflowjs_converter.
tensorflowjs_converter --input_format=tf_saved_model --output_format=tfjs_graph_model --...
0
votes
0
answers
48
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
3
answers
200
views
n_jobs>=2 breaks reproducibility
I am facing a problem in maintaining the reproducibility in the ML project. I believe the core snippet of my issue is
clf = Clf(random_state=cfg.seed)
# instantiate the K-fold cross-validation ...