im-ethz / pub-gdu4dg

Gated Domain Units (GDU) aim to make your deep learning models robust against distribution shifts when applied in the real-world.
MIT License
7 stars 0 forks source link

DomainCallback throws an error #5

Open alinadubatovka opened 2 years ago

alinadubatovka commented 2 years ago

https://github.com/im-ethz/pub-gdu4dg/blob/202219fccc75a65f691b5e05be8420b538749281/SimulationExperiments/digits5/digits_5_classification.py#L44

Traceback (most recent call last): File "SimulationExperiments/digits5/digits_5_classification.py", line 484, in run_experiment digits_classification(**experiment) File "SimulationExperiments/digits5/digits_5_classification.py", line 247, in digits_classification hist = model.fit(x=x_source_tr, y=y_source_tr, epochs=1, verbose=2, File "/cluster/project/jbuhmann/alinadu/miniconda3/envs/gdu4dg/lib/python3.8/site-packages/keras/engine/training.py", line 1230, in fit callbacks.on_epoch_end(epoch, epoch_logs) File "/cluster/project/jbuhmann/alinadu/miniconda3/envs/gdu4dg/lib/python3.8/site-packages/keras/callbacks.py", line 413, in on_epoch_end callback.on_epoch_end(epoch, logs) File "/cluster/project/jbuhmann/alinadu/pub-gdu4dg/Model/DomainAdaptation/domain_adaptation_callback.py", line 68, in on_epoch_end domain_train_prob = self.domain_layer.get_domain_prob(train_features).numpy() AttributeError: 'NoneType' object has no attribute 'get_domain_prob'

alinadubatovka commented 2 years ago

I believe that this if should be un-indented and placed outside of the except codeblock and it should stop the execution otherwise the error above occurs when the get_domain_prob method is called from None https://github.com/im-ethz/pub-gdu4dg/blob/604c152f3167ae9f8a6ef6c904abc90d77975cbf/Model/DomainAdaptation/domain_adaptation_callback.py#L49

Also, I don't understand which exception is thrown inside the try block above...

sfsouthpalatinate commented 2 years ago

The issue occurs only with TF 2.7.0. I downgraded TF to 2.4.1, as stated in the requirements, I don't get this error.