Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnboundLocalError: local variable 'batch_outputs' referenced before assignment #66

Open
Spartan859 opened this issue Aug 19, 2021 · 6 comments
Labels
bug Something isn't working

Comments

@Spartan859
Copy link

Epoch 150/150
42/42 [==============================] - 13s 321ms/step - loss: 5.8465e-05
Traceback (most recent call last):
File "/home/xuchun/.conda/envs/dannce/bin/com-train", line 33, in
sys.exit(load_entry_point('dannce', 'console_scripts', 'com-train')())
File "/home/xuchun/dannce/dannce/cli.py", line 42, in com_train_cli
com_train(params)
File "/home/xuchun/dannce/dannce/interface.py", line 661, in com_train
write_debug(trainData=False)
File "/home/xuchun/dannce/dannce/interface.py", line 624, in write_debug
label_out = model.predict(ims_valid, batch_size=1)
File "/home/xuchun/.conda/envs/dannce/lib/python3.7/site-packages/tensorflow/python/keras/engine/training.py", line 130, in _method_wrapper
return method(self, *args, **kwargs)
File "/home/xuchun/.conda/envs/dannce/lib/python3.7/site-packages/tensorflow/python/keras/engine/training.py", line 1614, in predict
all_outputs = nest.map_structure_up_to(batch_outputs, concat, outputs)
UnboundLocalError: local variable 'batch_outputs' referenced before assignment

When I finished training COM-finder, this happened.

How can I fix this?

@Spartan859
Copy link
Author

By the way, this only happened when num_validation_per_exp is set to 0.
When I change it to 2, there is no errors.

@Spartan859
Copy link
Author

However, the more validation samples you use, the fewer samples you can use for the actual training. We recommend using num_validation_per_exp: 0 unless you are using over 100 samples per animal.

According to this in ur wiki.

@Spartan859
Copy link
Author

Maybe this is because of the debug: True in com_config?

@spoonsso spoonsso added the bug Something isn't working label Aug 24, 2021
@spoonsso
Copy link
Owner

Yes, sorry. It is trying to save the predictions on the validation images when debug: True, but your ims_valid was empty because num_validation_per_exp.

@SwathiSheshadri
Copy link

I ran into the same issue after running several epochs of dannce-train. Would setting debug: False in the config file be sufficient to resolve this?

@spoonsso
Copy link
Owner

spoonsso commented Sep 15, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants