mostafaalishahi / eICU_Benchmark

36 stars 16 forks source link

Incompatible shapes when running bash_baseline.py #2

Closed jvpoulos closed 2 years ago

jvpoulos commented 3 years ago

I get the following error when running the baseline models. It seems as though there is a discrepancy in the size of the outputs when computing binary crossentropy loss.

I tried reducing batch size from 512 to 32 but it still produces the error.

Versions: TF 1.13.1 and Keras 2.3.1 .

Traceback (most recent call last): File "bash_baseline.py", line 36, in <module> output = main(config) File "/hpc/group/statdept/jvp5/storage/eICU_Benchmark/baseline.py", line 393, in main result = train_dec(config) File "/hpc/group/statdept/jvp5/storage/eICU_Benchmark/baseline.py", line 51, in train_dec model = network(config, 200, output_dim=1, activation='sigmoid') File "/hpc/group/statdept/jvp5/storage/eICU_Benchmark/models/models.py", line 188, in baseline_network model.compile(loss="binary_crossentropy" ,optimizer=optim, metrics=[metrics.f1,'accuracy']) File "/hpc/home/jvp5/.local/lib/python3.6/site-packages/keras/engine/training.py", line 222, in compile masks=masks) File "/hpc/home/jvp5/.local/lib/python3.6/site-packages/keras/engine/training.py", line 871, in _handle_metrics self._per_output_metrics[i], target, output, output_mask) File "/hpc/home/jvp5/.local/lib/python3.6/site-packages/keras/engine/training.py", line 842, in _handle_per_output_metrics metric_fn, y_true, y_pred, weights=weights, mask=mask) File "/hpc/home/jvp5/.local/lib/python3.6/site-packages/keras/engine/training_utils.py", line 1033, in call_metric_function update_ops = metric_fn.update_state(y_true, y_pred, sample_weight=weights) File "/hpc/home/jvp5/.local/lib/python3.6/site-packages/keras/utils/metrics_utils.py", line 42, in decorated update_op = update_state_fn(*args, **kwargs) File "/hpc/home/jvp5/.local/lib/python3.6/site-packages/keras/metrics.py", line 320, in update_state matches, sample_weight=sample_weight) File "/hpc/home/jvp5/.local/lib/python3.6/site-packages/keras/metrics.py", line 181, in update_state sample_weight = losses_utils.broadcast_weights(values, sample_weight) File "/hpc/home/jvp5/.local/lib/python3.6/site-packages/keras/utils/losses_utils.py", line 113, in broadcast_weights values_shape, weights_shape)) ValueError: Incompatible shapes:values() vssample_weight(None, 200)

mostafaalishahi commented 2 years ago

Thanks for your interest in this work, we have implemented neural networks using Keras 2.2.4 as mentioned in the GitHub readme file. Please check it out and let me know if you have still the same problem.