SuperBruceJia / EEG-Motor-Imagery-Classification-CNNs-TensorFlow

EEG Motor Imagery Tasks Classification (by Channels) via Convolutional Neural Networks (CNNs) based on TensorFlow
https://iopscience.iop.org/article/10.1088/1741-2552/ab4af6/meta
204 stars 47 forks source link

Incompatible shapes: [64,4] vs. [10,4] #6

Closed MuSamiNaf closed 3 years ago

MuSamiNaf commented 3 years ago

Hello Bruce I am trying to run the code MI_Proposed_CNNs_Architecture.py and I am having a problem at this line

sess.run(train_step, feed_dict={x: batch_xs, y: batch_ys, keep_prob: keep_rate}) It gives me this error

Exception has occurred: InvalidArgumentError
Incompatible shapes: [64,4] vs. [10,4]
     [[node sub_5 (defined at i:\IBM\CNN\Loss_Function\Loss.py:32) ]]

Errors may have originated from an input operation.
Input Source operations connected to node sub_5:
 Placeholder_1 (defined at i:\VBOX Shared Folder\IBM TUH Repo\CNN\main-CNN.py:58)   
 Softmax (defined at i:\IBM\CNN\Network\CNN.py:89)

Original stack trace for 'sub_5':
  File "C:\Users\******\Anaconda3\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Users\******\Anaconda3\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "c:\Users\******\.vscode\extensions\ms-python.python-2021.5.842923320\pythonFiles\lib\python\debugpy\__main__.py", line 45, in <module>
    cli.main()
  File "c:\Users\******\.vscode\extensions\ms-python.python-2021.5.842923320\pythonFiles\lib\python\debugpy/..\debugpy\server\cli.py", line 444, in main
    run()
  File "c:\Users\******\.vscode\extensions\ms-python.python-2021.5.842923320\pythonFiles\lib\python\debugpy/..\debugpy\server\cli.py", line 285, in run_file
    runpy.run_path(target_as_str, run_name=compat.force_str("__main__"))
  File "C:\Users\******\Anaconda3\lib\runpy.py", line 263, in run_path
    pkg_name=pkg_name, script_name=fname)
  File "C:\Users\******\Anaconda3\lib\runpy.py", line 96, in _run_module_code
    mod_name, mod_spec, pkg_name, script_name)
  File "C:\Users\******\Anaconda3\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "i:\IBM\CNN\main-CNN.py", line 65, in <module>
    loss = loss(y=y, prediction=prediction, l2_norm=True)
  File "i:\IBM\CNN\Loss_Function\Loss.py", line 32, in loss
    model_loss = tf.reduce_mean(tf.square(y - prediction))
  File "C:\Users\******\Anaconda3\lib\site-packages\tensorflow\python\ops\math_ops.py", line 1164, in binary_op_wrapper
    return func(x, y, name=name)
  File "C:\Users\******\Anaconda3\lib\site-packages\tensorflow\python\util\dispatch.py", line 201, in wrapper
    return target(*args, **kwargs)
  File "C:\Users\******\Anaconda3\lib\site-packages\tensorflow\python\ops\math_ops.py", line 561, in subtract
    return gen_math_ops.sub(x, y, name)
  File "C:\Users\******\Anaconda3\lib\site-packages\tensorflow\python\ops\gen_math_ops.py", line 10316, in sub
    "Sub", x=x, y=y, name=name)
  File "C:\Users\******\Anaconda3\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 750, in _apply_op_helper
    attrs=attr_protos, op_def=op_def)
  File "C:\Users\******\Anaconda3\lib\site-packages\tensorflow\python\framework\ops.py", line 3536, in _create_op_internal
    op_def=op_def)
  File "C:\Users\******\Anaconda3\lib\site-packages\tensorflow\python\framework\ops.py", line 1990, in __init__
    self._traceback = tf_stack.extract_stack()

During handling of the above exception, another exception occurred:

  File "i:\IBM\CNN\main-CNN.py", line 97, in <module>
    sess.run(train_step, feed_dict={x: batch_xs, y: batch_ys, keep_prob: keep_rate})

batch_xs.shape : (64, 640) batch_ys.shape : (64, 4) Where did the object which size is [10,4] came from?!

Thank you

MuSamiNaf commented 3 years ago

May I understand why the issue was closed without a reply? Thank you for your time!

SuperBruceJia commented 3 years ago

May I understand why the issue was closed without a reply? Thank you for your time!

Hi,

Good morning!

Sorry for the delayed response, and thanks a lot for your interest in our work.

The repo is simply a demo of EEG signals classification based on the Convolutional Neural Networks. The codes haven't been correctly organized, and you are encouraged to solve the issues by yourself.

Alternatively, you are suggested to take a look at the EEG-DL repo, try to implement the algorithms, and reproduce the results.

If you have additional questions, please don't hesitate to reply to this message.

Have a nice day!

Best,

Shuyue Sep 16, 2021