#๐ Tensor flow NoneType error
114 messages ยท Page 1 of 1 (latest)
@shell oxide
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
Hello everyone, im trying to train a model using tensorflow and i keep getting this error AttributeError: 'NoneType' object has no attribute 'dtype' and i can't figure out why it's happening even though i added lots of debugging statements in my code to attempt to track what's giving None before passing it to tensorflow but it's still there and im kinda beat, it's been hours im trying to diagnose this and no luck, id appreciate if anyone can give me ideas on what could be causing this:
my code currently:
https://paste.pythondiscord.com/SRPA
Tensorflow NoneType error
full error:
https://paste.pythondiscord.com/DMWA
Your set up seems to be the issue
how?
The functionality seems to be incorrect for each function you intend this for
the intention is to convert pdf to latex
so im training a model with existing pdfs and latex
i run ocr using ocrmypdf then extract the text with pdfplumber from the searchable pdf
and link them with their corresponding latex
idk is there something im doing wrong?
What kind of pdfs
Bank records, node codes, source codes for smart contracts, mining
Can you give me a breakdown of what you want the code to do precisely...you seem to be adding the wrong commands
for this specific code i want to train it on how to recognize ocr text and convert it to latex, by feeding it a bunch of pdfs that have i done ocr on them and correspond them with their latex
all in 1 json file
fed to t5-base
it starts fine at first but then it just errors midway
lemme show u
You can't use one json file
Did you create a contract you're trying to call from?
Or just want to calculate the earnings, future investment plans.....there's a lot to it
none of that, i just want to convert a specific format of exams in my country here to latex
im using a very specific dataset
What country?
Tunisia
The primary goal is to convert OCR processed text from math exams in pdf format to latex format. this involves training a model using existing pdf and latex pairs
Hold on a sec
Hello
Uninitialized variables: Make sure that all variables are initialized before passing them to the compile() method. Check if you've assigned values to optimizer, loss, and metrics before compiling the model.
Incorrectly defined variables: Double-check that the variables are correctly defined and have the expected types. For example, make sure that optimizer is a string or a TensorFlow optimizer object, and not a None value.
Model not built correctly: Ensure that you've built your model correctly using the Sequential API or the Keras functional API. If your model is not built correctly, it won't have a compile() method.
To debug this further, I recommend adding more print statements to track the values of these variables before passing them to the compile() method.
print(optimizer)
print(loss)
print(metrics)
print(type(optimizer))
print(type(loss))
print(type(metrics))
alright give me a second let me do that
Alright
All OCR-LaTeX pairs are valid.
All PyTorch model weights were used when initializing TFT5ForConditionalGeneration.
All the weights of TFT5ForConditionalGeneration were initialized from the PyTorch model.
If your task is similar to the task the model of the checkpoint was trained on, you can already use TFT5ForConditionalGeneration for predictions without further training.
Optimizer: <tf_keras.src.optimizers.adam.Adam object at 0x0000028307F599A0>
Debugging information before model compile:
Optimizer: <tf_keras.src.optimizers.adam.Adam object at 0x0000028307F599A0>
Loss: <bound method TFPreTrainedModel.compute_loss of <transformers.models.t5.modeling_tf_t5.TFT5ForConditionalGeneration object at 0x00000283792C54F0>>
Type of optimizer: <class 'tf_keras.src.optimizers.adam.Adam'>
Type of loss: <class 'method'>
okay i suspect it's still the same problem but i have suspicion why it could be happening
im suspecting it's the optimizer
for it to work i had to set this in env os.environ['TF_USE_LEGACY_KERAS'] = '1'
without it ill just get this error: ValueError: Could not interpret optimizer identifier: <keras.src.optimizers.adam.Adam object at 0x0000021E6E5A1400>
Is this a wallet address
no it's not
if u mean a crypto address
ok im just gonna use another optimizer see what happens
RMSprop should do the job
Do you have good RPC
Try this
i seem to be getting the same error:
ValueError: Could not interpret optimizer identifier: <keras.src.optimizers.rmsprop.RMSprop object at 0x0000019EAAA1A480>
something is wrong with tensorflow
i gotta figure it out
You don't own the source code for this right?
i made this lol
Let me try and understand this more
you have a pdf
an image pdf for example
u can't edit
you read it using already trained ocr software
then that text, we need it to be converted to latex
so to do that, we get a bunch of pdfs that have been read with the same ocr software we gonna use later for production
and pair with it's corresponding, correct latex
and train an open weight model like t5 to be able to recognize and predict more of that text
the logic is simple, coding is what's annoying
Which ocr did you use again
for the version i sent it's ocrmypdf which is open source https://github.com/ocrmypdf/OCRmyPDF
the one im gonna be using later is a pretrained model that i've trained for a 3 months now
it can read better
but this should work too with test dataset im using
Whats the name
OCRmyPDF
Did you tru TESSERACT OCR engine
Production of what?
production of a software that can convert exams to latex
lots of exams in here are outdated so converting them to latex
will modernize them
since latex is best with math
Microsoft azure
Google tensorflow?
you mean google vision api?
that one costs money
just like mathpix
just like azure
I think that's the issue
Nothing seems to be wrong woth the code. I think you need a more accurate OCR
You can actually, after running this test you'll be able to create a duplicate based of the inference created by azure
So your model will not only be totally controlled by you but also accurate and up to date.
Due to machine learning
Yeah, but you don't have a subscription do you
Rn the problem isn't with ocr but this little part here, for some reason whatever optimizer i use, i get the same error
from tensorflow.keras.optimizers import RMSprop
from tensorflow.keras.callbacks import EarlyStopping, ModelCheckpoint
(....)
optimizer = tf.keras.optimizers.RMSprop(learning_rate=5e-5)
print(f"Optimizer: {optimizer}")
print("Debugging information before model compile:")
print("Optimizer:", optimizer)
print("Loss:", model.compute_loss)
print("Type of optimizer:", type(optimizer))
print("Type of loss:", type(model.compute_loss))
model.compile(optimizer=optimizer, loss=model.compute_loss)
print("Model compiled successfully.")
(...)
ValueError: Could not interpret optimizer identifier: <keras.src.optimizers.rmsprop.RMSprop object at 0x00000219F47324B0>
am i doing something wrong
ill get it, if all else fails
right here im just trying to compile the model, didn't pass even pass the data yet
it doesn't compile because of that optimizer error
So... Still think its there?
yes because i just fixed it
!warn 1100300248280219648 using generative AI to produce answers is against the rules. If you don't understand what is being asked, don't disserve the asker by posting an answer that you don't understand, either.
:incoming_envelope: :ok_hand: applied warning to @real flicker.
and please stop bringing up crypto.
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.