ValueError: Error when checking input: expected input_1 to have 2 dimensions, but got array with shape (100, 100, 100, 3)


原文鏈接:http://www.one2know.cn/bug6/

  • 報錯
Traceback (most recent call last):
  File "D:/PyCharm 5.0.3/WorkSpace/3.Keras/1.Sequential與Model模型、Keras基本結構功能/2_1.py", line 22, in <module>
    model.fit(data,labels,epochs=3)
  File "D:\Anaconda3\lib\site-packages\keras\engine\training.py", line 952, in fit
    batch_size=batch_size)
  File "D:\Anaconda3\lib\site-packages\keras\engine\training.py", line 751, in _standardize_user_data
    exception_prefix='input')
  File "D:\Anaconda3\lib\site-packages\keras\engine\training_utils.py", line 128, in standardize_input_data
    'with shape ' + str(data_shape))
ValueError: Error when checking input: expected input_1 to have 2 dimensions, but got array with shape (100, 100, 100, 3)
  • 原因
    輸入第一層的張量與數據集的shape不同
  • 解決
    將data轉置:
    data = data.reshape(len(data),-1)
    然后會報錯:
ValueError: Error when checking input: expected input_1 to have shape (784,) but got array with shape (300,)

再把shape按照提示改正:
inputs = Input(shape=(300,))


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM