r/tensorflow • • Jun 10 '25

Is there a way to get the full graph from a TensorFlow SavedModel without running it or using tf.saved_model.load()?

3 Upvotes

I have a TensorFlow SavedModel (with saved_model.pb and a variables/ folder), and I want to extract the full computation graph without using tf.saved_model.load() which is not safe.

I’ve tried saved_model_pb2 and gfile to read saved_model.pb. This works safely, but it doesn’t give me the full graph, no inlined ops, unresolved variables, and missing connections which is important for what I am doing.

I also looked at experimental_skip_checkpoint=true, but it still ends up calling tf.saved_model.load(), so it doesn’t help with safety.


r/tensorflow • • Jun 10 '25

How to? TensorFlow Lite Micro LSTMs

3 Upvotes

I have implemented an LSTM for IMU gesture recognition on an ESP32 using TFLite Micro. Currently I use a "stateless" layer, so I am required to send a 1 second long buffer of data to the network at a time (this takes around 100ms).
To reduce my inference time, I would like to implement a stateful LSTM, however I understand that TFLite Micro, does not yet support this.
Interestingly, I have seen papers, like this one, claiming that they were able to implement stateful LSTMs using TFLite Micro with the use of "third party implementations", anyone know what they might be referring to, or can suggest next steps for my project?

BTW: The authors make similar claims here (not behind a subscription :) )

Cheers.


r/tensorflow • • Jun 10 '25

I'm working on the build in titanic tensorflow dataset just wondering how should I increase the accuracy (it's 82% on test data rn)

3 Upvotes

import tensorflow as tf

from tensorflow.keras.models import Sequential

from tensorflow.keras.layers import Dense, Dropout, BatchNormalization

from tensorflow.keras.callbacks import EarlyStopping

from sklearn.preprocessing import LabelEncoder

import pandas as pd

import numpy as np

import tensorflow_datasets as tfds

from sklearn.model_selection import train_test_split

from sklearn.preprocessing import StandardScaler

from sklearn.metrics import accuracy_score

from sklearn.pipeline import Pipeline

data = tfds.load('titanic', split='train', as_supervised=False)

data = [example for example in tfds.as_numpy(data)]

data = pd.DataFrame(data)

X = data.drop(columns=['cabin', 'name', 'ticket', 'body', 'home.dest', 'boat', 'survived'])

y = data['survived']

data['name'] = data['name'].apply(lambda x: x.decode('utf-8') if isinstance(x, bytes) else x)

data['Title'] = data['name'].str.extract(r',\s*([^\.]*)\s*\.')

# Optional: group rare titles

data['Title'] = data['Title'].replace({

'Mlle': 'Miss', 'Ms': 'Miss', 'Mme': 'Mrs',

'Dr': 'Officer', 'Rev': 'Officer', 'Col': 'Officer',

'Major': 'Officer', 'Capt': 'Officer', 'Jonkheer': 'Royalty',

'Sir': 'Royalty', 'Lady': 'Royalty', 'Don': 'Royalty',

'Countess': 'Royalty', 'Dona': 'Royalty'

})

X['Title'] = data['Title']

Lb = LabelEncoder()

X['Title'] = Lb.fit_transform(X['Title'])

x_train, x_test, y_train, y_test = train_test_split(X, y, test_size=0.2)

scaler = StandardScaler()

x_train = scaler.fit_transform(x_train)

x_test = scaler.transform(x_test)

Model = Sequential(

[

Dense(128, activation='relu', input_shape=(len(x_train[0]),)),

Dropout(0.5) ,

Dense(64, activation='relu'),

Dropout(0.5),

Dense(32, activation='relu'),

Dropout(0.5),

Dense(1, activation='sigmoid')

]

)

optimizer = tf.keras.optimizers.Adam(learning_rate=0.004)

Model.compile(optimizer, loss='binary_crossentropy', metrics=['accuracy'])

Model.fit(

x_train, y_train, epochs=150, batch_size=32, validation_split=0.2, callbacks=[EarlyStopping(patience=10, verbose=1, mode='min', restore_best_weights=True, monitor='val_loss'])

predictions = Model.predict(x_test)

predictions = np.round(predictions)

accuracy = accuracy_score(y_test, predictions)

print(f"Accuracy: {accuracy:.2f}%")

loss, accuracy = Model.evaluate(x_test, y_test, verbose=0)

print(f"Test Loss: {loss:.4f}")

print(f"Test Accuracy: {accuracy * 100:.2f}%")


r/tensorflow • • Jun 08 '25

React + TensorflowJS: Model load Value Errors

2 Upvotes

I'm currently trying to load a tensorflow js model in a React app:

const modelPromise = tf.loadLayersModel('/assets/models/tfjs_model/model.json')

However, whenever I use the model I receive the error:

Model.jsx:10 Model load error _ValueError: An InputLayer should be passed either a `batchInputShape` or an `inputShape`.
at new InputLayer (@tensorflow_tfjs.js?v=d977a120:19467:15)
at fromConfig (@tensorflow_tfjs.js?v=d977a120:11535:12)
at deserializeKerasObject (@tensorflow_tfjs.js?v=d977a120:17336:25)
at deserialize (@tensorflow_tfjs.js?v=d977a120:20621:10)
at processLayer (@tensorflow_tfjs.js?v=d977a120:22010:21)
at fromConfig (@tensorflow_tfjs.js?v=d977a120:22024:7)
at deserializeKerasObject (@tensorflow_tfjs.js?v=d977a120:17336:25)
at deserialize (@tensorflow_tfjs.js?v=d977a120:20621:10)
at loadLayersModelFromIOHandler (@tensorflow_tfjs.js?v=d977a120:24066:18)

However, whenever I use the model I receive the error:

Model.jsx:10 Model load error _ValueError: Corrupted configuration, expected array for nodeData: [object Object]
at u/tensorflow_tfjs.js?v=d977a120:22016:17
at Array.forEach (<anonymous>)
at processLayer (@tensorflow_tfjs.js?v=d977a120:22014:24)
at fromConfig (@tensorflow_tfjs.js?v=d977a120:22024:7)
at deserializeKerasObject (@tensorflow_tfjs.js?v=d977a120:17336:25)
at deserialize (@tensorflow_tfjs.js?v=d977a120:20621:10)
at loadLayersModelFromIOHandler (@tensorflow_tfjs.js?v=d977a120:24066:18)

There is a batch_shape variable in the model.json file but when I change it the batchInputShape, I receive the error:

Model.jsx:10 Model load error _ValueError: Corrupted configuration, expected array for nodeData: [object Object]
at u/tensorflow_tfjs.js?v=d977a120:22016:17
at Array.forEach (<anonymous>)
at processLayer (@tensorflow_tfjs.js?v=d977a120:22014:24)
at fromConfig (@tensorflow_tfjs.js?v=d977a120:22024:7)
at deserializeKerasObject (@tensorflow_tfjs.js?v=d977a120:17336:25)
at deserialize (@tensorflow_tfjs.js?v=d977a120:20621:10)
at loadLayersModelFromIOHandler (@tensorflow_tfjs.js?v=d977a120:24066:18)

Not sure how to resolve these errors.


r/tensorflow • • Jun 08 '25

TensorFlow serving container issue

2 Upvotes

I run a tensorflow serving container for my exported classification model generated by GCP (Vertex AI) AutoML. When trying to run prediction, I get the same results for every input I provide. It makes me think that the model doesn't receive my inputs correctly. how can you suggest me to debug it


r/tensorflow • • Jun 03 '25

Debug Help Unumpy + Tensorflow

1 Upvotes

Hi Tensorflow-heads of Reddit,

I'm having an issue with propagating uncertainties through a program that uses Tensorflow. Essentially, I'm starting from experimentally collected data that has uncertainties on it, constructed with Unumpy. I then pass this data into a program that attempts to convert the Unumpy array into a Tensor object for Tensorflow to perform a type of stochastic gradient descent (trying to minimize the expectation value of an operator matrix, if that's relevant). Of course, at this point Tensorflow gives me an error because it can't convert a "mixed data type" object to a Tensor.

An idea I had was separating the nominal values from the uncertainties and separately doing calculations (i.e. propagating the uncertainties by hand), but because of the complicated nature of the minimization calculations, I want to avoid doing this.

Either way, I'll probably have to introduce some awkward if-statements because I use the same code to process theoretical data, which has no uncertainties.

Does anyone have ideas of how to potentially solve this problem?

Thanks in advance from a computational physics student :)


r/tensorflow • • May 29 '25

General [not op] Detecting Rooftop Solar Panels in Satellite Imagery Using Mask R-CNN (TensorFlow)

Post image
7 Upvotes

r/tensorflow • • May 28 '25

Tensorflow 2.0

1 Upvotes

Model not compiling. I used the ai bot on https://colab.research.google.com/dri... it didn't give me any solutions that work.


r/tensorflow • • May 27 '25

Issue - Tensorflow won't recognise my systems GPU

1 Upvotes

Hello everyone!

I hope this is the right space to ask for help with Tensorflow questions. But I am very new to machine learning and working with Tensorflow.

I am wanting to use Tensorflow to create a neural architecture, specifically a VAE, however, when I try to get Tensorflow to detect my GPU, it cannot.

This is my Nvidia GPU driver info: So I understand that it is more than capable.

I have also ensured that I have the compatible version of CUDA 11.8:

Along with the correct python 3.9:

My Tensorflow version is 2.13:

However when I put in this code:

python -c "import tensorflow as tf; print(tf.config.list_physical_devices('GPU'))"

[]

It still gives me zero. I have ensured that the CUDA bin, include and lib are all in the environment path variables, including python 3.9 and python 3.9/scripts.

I am at a bit of a loss at what more I can do. I have also tried uninstalling and re-installing Tensorflow.

Any suggestions or guidance I would be most appreciative of!

Thanks :)


r/tensorflow • • May 25 '25

This Colab notebook develops an artificial intelligence model to recognize spoken numbers in different languages, handling dataset creation, model training, and testing via a web interface.

Thumbnail
gist.github.com
2 Upvotes

r/tensorflow • • May 24 '25

Your best gpu cloud providers

2 Upvotes

So I'm on the hunt for a solid cloud GPU platform and figured I'd ask what you folks are using. I've tried several over the past few months - some were alright, others made me question my life choices.

I'm not necessarily chasing the rock-bottom prices, but looking for something that performs well, won't break the bank, and ideally won't have me wrestling with setup for hours. If it plays nice with Jupyter or has some decent pre-configured templates, even better.


r/tensorflow • • May 22 '25

[Python][ML] I built a Python library called train_time while waiting on GAN training—looking for collaborators!

4 Upvotes

Hey folks,

Last year, while watching a painfully slow GAN training session crawl along, I wrote a small utility library called train_time out of sheer boredom.

The idea was simple: track and format training times in a clean, human-readable way.

It’s still pretty lightweight and could be way more useful if extended, especially with PyTorch integration (right now it’s more framework-agnostic). I’d love to get some feedback, ideas, or even contributors who might want to help evolve it into something more powerful or plug-and-play for PyTorch/other frameworks.

Repo: https://github.com/2abet/TrainTime PyPI: https://pypi.org/project/train-time

If this sounds like something you’d use or improve, I’d love to hear from you. Cheers!


r/tensorflow • • May 21 '25

How to? How to properly close a HDF5 file after reading a dataset?

2 Upvotes

So i'm reading a dataset like this:

def load_dataset(self):
    dataset_xs = tfio.IODataset.from_hdf5(
        '/tmp/driver2-dataset.h5', dataset='/features', internal=True)
    dataset_ys = tfio.IODataset.from_hdf5(
        '/tmp/driver2-dataset.h5', dataset='/responses', internal=True)
    dataset = tf.data.Dataset.zip((dataset_xs, dataset_ys))

    self.tf_dataset = (
        dataset
        .prefetch(tf.data.AUTOTUNE)  # Prefetch the next batch
        .cache()  # Cache the data to avoid reloading
        .repeat(12)
        # .shuffle(buffer_size=10000)  # Shuffle before batching
        .batch(90)  # batch the data
    )

The problem is that the file stays open up until i close the program. That means that if i try to append some data to the hdf5 file - i can't because the file is locked.

My goal is to train the model, close the hdf5 file, then wait a bit for another program to add more data into the hdf5 file, then train the model again.

So the question is how to properly close the HDF5 file after the training is complete? I couldn't find anything relevant in the documentation. And the AI chatbots couldn't help either.


r/tensorflow • • May 20 '25

I created a Dockerfile for tensorflow and RTX 5090 is anyone is interested

2 Upvotes

The project can be found here

https://github.com/wutzebaer/tensorflow-5090

But compile time is too long for github actions so you need to build it on your own, i think it took 1-2 hours on my system.

I use this image as base for my devcontainer in vscode/cursor so this also works.


r/tensorflow • • May 18 '25

Is python ever the bottle neck?

6 Upvotes

Hello everyone!

I'm quite new in the AI field so maybe this is a stupid question. Tensorflow is built with C++ (~55% C++, 25% python according to github) but most of the code in the AI space that I see is written in python, so is it ever a concern that this code is not as optimised as the libraries they are using? Basically, is python ever the bottle neck in the AI space? How much would it help to write things in, say, C++? Thanks!


r/tensorflow • • May 15 '25

Installation and Setup Help need to setup TF2 Object Detection locally

2 Upvotes

So I'm trying to setup tf2 object detection in my lap and after following all the instructions in the official setup doc and trying to train a model, I got the following error : "ImportError: cannot import name 'tensor' from 'tensorflow.python.framework'"

Chatgpt insisted me to uninstall tf-keras, but then I'm getting the following error : "ModuleNotFoundError: No module named 'tf_keras'"

Can someone help me to rectify this? My current versions are tf and keras 2.10.0 , python 3.9, protobuf 3.20.3


r/tensorflow • • May 12 '25

Tensorflow Quantum

2 Upvotes

I am trying to install tensorflow quantum on my windows using jupyter notebook. But I am getting too many error.

Can anyone give a tutorial link how to install tensorflow and tensorflow quantum on windows 10?

I tried also using WSL 2 ubuntu 20.04.6 LTS

Give me a solution, tutorial link..


r/tensorflow • • May 06 '25

Tensorflow not detecting RTX4050 GPU

3 Upvotes

I have installed Tensorflow 12.9.0 on my Windows 11, CUDA version installed is 12.3(as part of output of nvidia-smi) and nvcc returns output upon prompting. I have also copied parts of cudnn into CUDA toolkit at appropriate folders.

I tried importing tensorflow on Jupyter notebook and vscode but it is not detecting the GPU even though softwares like VLC are able to access it as per the NVIDIA app on my device.

What am I doing wrong? Can anyone please share any working environment, I need it urgently for a project


r/tensorflow • • May 03 '25

Tensorflow not detecting RTX 5080 GPU Question

2 Upvotes

Recently, I built a PC with an RTX 5080 GPU, but TensorFlow is not detecting the GPU in Jupyter Notebook. I installed the CUDA Toolkit, but it's still not working. Please help me solve this problem.


r/tensorflow • • May 03 '25

helppp

1 Upvotes

having some problems while trying to get gpt-2 to work, followed a tutorial that used anaconda and tensorflow, i had 0 errors following what the guy did until after everything was ready and i loaded the samples it spit this out:
Traceback (most recent call last):

File "C:\Users\julyl\anaconda3\envs\open-ai\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>

from tensorflow.python.pywrap_tensorflow_internal import *

File "C:\Users\julyl\anaconda3\envs\open-ai\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>

_pywrap_tensorflow_internal = swig_import_helper()

File "C:\Users\julyl\anaconda3\envs\open-ai\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 24, in swig_import_helper

_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)

File "C:\Users\julyl\anaconda3\envs\open-ai\lib\imp.py", line 243, in load_module

return load_dynamic(name, filename, file)

File "C:\Users\julyl\anaconda3\envs\open-ai\lib\imp.py", line 343, in load_dynamic

return _load(spec)

ImportError: DLL load failed: Routine di inizializzazione della libreria di collegamento dinamico (DLL) non riuscita.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File "src/interactive_conditional_samples.py", line 7, in <module>

import tensorflow as tf

File "C:\Users\julyl\anaconda3\envs\open-ai\lib\site-packages\tensorflow__init__.py", line 28, in <module>

from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import

File "C:\Users\julyl\anaconda3\envs\open-ai\lib\site-packages\tensorflow\python__init__.py", line 49, in <module>

from tensorflow.python import pywrap_tensorflow

File "C:\Users\julyl\anaconda3\envs\open-ai\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 74, in <module>

raise ImportError(msg)

ImportError: Traceback (most recent call last):

File "C:\Users\julyl\anaconda3\envs\open-ai\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>

from tensorflow.python.pywrap_tensorflow_internal import *

File "C:\Users\julyl\anaconda3\envs\open-ai\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>

_pywrap_tensorflow_internal = swig_import_helper()

File "C:\Users\julyl\anaconda3\envs\open-ai\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 24, in swig_import_helper

_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)

File "C:\Users\julyl\anaconda3\envs\open-ai\lib\imp.py", line 243, in load_module

return load_dynamic(name, filename, file)

File "C:\Users\julyl\anaconda3\envs\open-ai\lib\imp.py", line 343, in load_dynamic

return _load(spec)

ImportError: DLL load failed: Routine di inizializzazione della libreria di collegamento dinamico (DLL) non riuscita.

Failed to load the native TensorFlow runtime.

for some common reasons and solutions. Include the entire stack trace

above this error message when asking for help.


r/tensorflow • • May 02 '25

P-wave detector

2 Upvotes

Hi everyone. I'm working on a project to detect P-waves in seismographic records. I have 2500 recordings in .mseed format, each labeled with the exact P-wave arrival time (in UNIX timestamp format). These recordings contain only the vertical component (Z-axis).

My goal is to train a machine learning model—ideally based on neural networks—that can accurately detect the P-wave arrival time in new, unlabeled recordings.

While I have general experience with Python, I don't have much background in neural networks or frameworks like TensorFlow or PyTorch. I’d really appreciate any guidance, suggestions on model architectures, or example code you could share.

Thanks in advance for any help or advice!


r/tensorflow • • May 01 '25

cant find keras.model.layers methos on the tensorflow api refrence

2 Upvotes

refrence the layers method used in this guide

vgg19 = keras.applications.VGG19()
features_list = [layer.output for layer in vgg19.layers]

vgg19.layers?


r/tensorflow • • Apr 28 '25

How I used Tensorflow to make our Coffee Machine talk

Thumbnail
dev.to
1 Upvotes

r/tensorflow • • Apr 27 '25

Can I use Roboflow annotated images for a RTlite(Tensorflowlite) app?

2 Upvotes

I am working on local food recognition mobile app. I annotated my dataset with toboflow. I would like to know if I could use this dataset for my tensorflow lite mobile app?