Problem running the code
Closed this issue · 3 comments
Hi, when I run the CANN4brain_main.py code I get the following error:
Traceback (most recent call last):
File "CANN4brain_main.py", line 304, in
model_given, history = Compile_and_fit(model_given, input_train, output_train, epochs, path_checkpoint, sample_weights)
File "CANN4brain_main.py", line 142, in Compile_and_fit
history = model_given.fit(input_train,
File "/home/jperg/venv/lib/python3.8/site-packages/keras/src/utils/traceback_utils.py", line 70, in error_handler
raise e.with_traceback(filtered_tb) from None
File "/tmp/autograph_generated_filega2ntee1.py", line 15, in tf__train_function
retval = ag_.converted_call(ag__.ld(step_function), (ag__.ld(self), ag__.ld(iterator)), None, fscope)
TypeError: in user code:
File "/home/jperg/venv/lib/python3.8/site-packages/keras/src/engine/training.py", line 1338, in train_function *
return step_function(self, iterator)
File "/home/jperg/venv/lib/python3.8/site-packages/keras/src/engine/training.py", line 1322, in step_function **
outputs = model.distribute_strategy.run(run_step, args=(data,))
File "/home/jperg/venv/lib/python3.8/site-packages/keras/src/engine/training.py", line 1303, in run_step **
outputs = model.train_step(data)
File "/home/jperg/venv/lib/python3.8/site-packages/keras/src/engine/training.py", line 1085, in train_step
return self.compute_metrics(x, y, y_pred, sample_weight)
File "/home/jperg/venv/lib/python3.8/site-packages/keras/src/engine/training.py", line 1179, in compute_metrics
self.compiled_metrics.update_state(y, y_pred, sample_weight)
File "/home/jperg/venv/lib/python3.8/site-packages/keras/src/engine/compile_utils.py", line 577, in update_state
self.build(y_pred, y_true)
File "/home/jperg/venv/lib/python3.8/site-packages/keras/src/engine/compile_utils.py", line 483, in build
self._metrics = tf.__internal__.nest.map_structure_up_to(
TypeError: If shallow structure is a sequence, input must also be a sequence. Input has type: <class 'tensorflow.python.framework.ops.Tensor'>.
does anyone else have this problem or know how to solve it?
It is when te case: Region: CC | Fitting Mode: TC is running
I have the same problem. Have you solved it?
For the case of fitting tension, compression, and shear simultaneously please try using double brackets like in the Jupyter Notebook for the stretch-based brain model:
input_train = [[lam_ut], [gamma_ss]]
output_train = [[P_ut], [P_ss]]
sample_weights_tc = weighing_TC
sample_weights_ss = np.array([1.0]*gamma_ss.shape[0])
sample_weights = [[sample_weights_tc], [sample_weights_ss]]
The Jupyter notebook contains the invariant-based model as well, so please try using that instead of the python code and see if that solves your issues. The Graz workshop folder contains more explicit instructions if you have not worked with Jupyter notebooks before. In general, we have found that different OS and different package versions influence whether there are issues with running the python code, so we developed the notebook to make the code more readily accessible.