MIDASpy icon indicating copy to clipboard operation
MIDASpy copied to clipboard

Incompatible shapes error while running MIDAS recursively

Open infiniteline opened this issue 1 year ago • 1 comments

Hi all,

I'm recursively running imputation on a dataset of participants (using only each participant's data to train the model). It runs fine but throws an error with the 127th participant. If I run the code again (even without re-initializing the model), and only use the data for that participant, it runs fine. Any suggestions?

Here's a chunk of the error:

---------------------------------------------------------------------------
InvalidArgumentError                      Traceback (most recent call last)
File ~/opt/anaconda3/lib/python3.9/site-packages/tensorflow/python/client/session.py:1378, in BaseSession._do_call(self, fn, *args)
   1377 try:
-> 1378   return fn(*args)
   1379 except errors.OpError as e:

File ~/opt/anaconda3/lib/python3.9/site-packages/tensorflow/python/client/session.py:1361, in BaseSession._do_run.<locals>._run_fn(feed_dict, fetch_list, target_list, options, run_metadata)
   1360 self._extend_graph()
-> 1361 return self._call_tf_sessionrun(options, feed_dict, fetch_list,
   1362                                 target_list, run_metadata)

File ~/opt/anaconda3/lib/python3.9/site-packages/tensorflow/python/client/session.py:1454, in BaseSession._call_tf_sessionrun(self, options, feed_dict, fetch_list, target_list, run_metadata)
   1452 def _call_tf_sessionrun(self, options, feed_dict, fetch_list, target_list,
   1453                         run_metadata):
-> 1454   return tf_session.TF_SessionRun_wrapper(self._session, options, feed_dict,
   1455                                           fetch_list, target_list,
   1456                                           run_metadata)

InvalidArgumentError: Incompatible shapes: [15] vs. [0]
	 [[{{node AdamW/gradients/gradients/mean_squared_error_2/SquaredDifference_grad/mul_1}}]]

NOTE: I'm not running tensorflow < 2.12 as there doesn't seem to be an ARM distribution for that version. Seems to run well most of the time, but... ?

infiniteline avatar Apr 18 '25 22:04 infiniteline

I'm still not sure what causes the posted error, but I've been getting around these failures by just changing my loop to run the remainder of the participants and it usually completes without another error.

infiniteline avatar Apr 19 '25 07:04 infiniteline