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

Graph execution error: Detected at node 'Adam/StatefulPartitionedCall_2' #18

Open
rollwan opened this issue Sep 26, 2023 · 1 comment
Open

Comments

@rollwan
Copy link

rollwan commented Sep 26, 2023

When I fiting DNN model in the Examples_decoders_hc.ipynb, it comes an error below:

FailedPreconditionError Traceback (most recent call last)
Input In [93], in <cell line: 5>()
2 model_dnn=DenseNNDecoder(units=100,dropout=0.25,num_epochs=10)
4 #Fit model
----> 5 model_dnn.fit(X_flat_train,y_train)
7 #Get predictions
8 y_valid_predicted_dnn=model_dnn.predict(X_flat_valid)

File ~/.local/lib/python3.8/site-packages/Neural_Decoding/decoders.py:396, in DenseNNRegression.fit(self, X_flat_train, y_train)
394 model.fit(X_flat_train,y_train,nb_epoch=self.num_epochs,verbose=self.verbose) #Fit the model
395 else:
--> 396 model.fit(X_flat_train,y_train,epochs=self.num_epochs,verbose=self.verbose) #Fit the model
397 self.model=model

File ~/.local/lib/python3.8/site-packages/keras/src/utils/traceback_utils.py:70, in filter_traceback..error_handler(*args, **kwargs)
67 filtered_tb = _process_traceback_frames(e.traceback)
68 # To get the full stack trace, call:
69 # tf.debugging.disable_traceback_filtering()
---> 70 raise e.with_traceback(filtered_tb) from None
71 finally:
72 del filtered_tb

File ~/.local/lib/python3.8/site-packages/tensorflow/python/eager/execute.py:53, in quick_execute(op_name, num_outputs, inputs, attrs, ctx, name)
51 try:
52 ctx.ensure_initialized()
---> 53 tensors = pywrap_tfe.TFE_Py_Execute(ctx._handle, device_name, op_name,
54 inputs, attrs, num_outputs)
55 except core._NotOkStatusException as e:
56 if name is not None:

FailedPreconditionError: Graph execution error:

Detected at node 'Adam/StatefulPartitionedCall_2' defined at (most recent call last):
File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,

@jglaser2
Copy link
Collaborator

I'm not sure, as this seems to be a keras/tensorflow issue.

One possible suggestion (coming from here: https://stackoverflow.com/questions/71153492/invalid-argument-error-graph-execution-error) is that it may relate to different versions of the Adam optimizer within different versions of tensorflow.

In decoders.py line 392, you could change this to:

opt = Adam()
model.compile(loss='mse',optimizer=opt,metrics=['accuracy'])  #Set loss function and optimizer

And after line 52 add

from tensorflow.keras.optimizers.legacy import Adam

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants