teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

1

回答者からの質問追加の要求

2020/07/12 12:15

投稿

huton
huton

スコア30

title CHANGED
File without changes
body CHANGED
@@ -77,7 +77,8 @@
77
77
  # pickle.dump(model, f)
78
78
  model.save("sign.h5")
79
79
  ```
80
- **参考にさせていだいたソースコード**
80
+ **エラーが発生したソースコード**
81
+ エラーの発生した行に(*)と書きました。
81
82
  ```python
82
83
  from keras.models import load_model
83
84
  import numpy as np
@@ -119,7 +120,7 @@
119
120
  Xt.append(th)
120
121
  Xt = np.array(Xt)/255
121
122
 
122
- result = model.predict(Xt, batch_size=1) # 判定,ソート
123
+ (*) result = model.predict(Xt, batch_size=1) # 判定,ソート
123
124
  for i in range(24):
124
125
  r = round(result[0,i], 2)
125
126
  Yt.append([i, r])
@@ -143,5 +144,14 @@
143
144
  ```
144
145
  エラーメッセージ
145
146
  ```python
147
+ Traceback (most recent call last):
148
+ File "kamera.py", line41, in <module>
149
+ result = model.predict(Xt, batch_size=1) # 判定,ソート
150
+ File "C:\Users(ユーザー名)\anaconda3\lib\site-packages\keras\engine\training.py", line 1441, in predict
151
+ x, _, _ =self._standardize_user_data(x)
152
+ File "C:\Users(ユーザー名)\anaconda3\lib\site-packages\keras\engine\training.py", line 579, in _standardize_user_data
153
+ exception_prefix='input')
154
+ File "C:\Users(ユーザー名)\anaconda3\lib\site-packages\keras\engine\training_utils.py", line 135, in standardize_input_data
155
+ 'with shape ' + str(data_shape))
146
156
  ValueError: Error when checking input: expected conv2d_1_input to have 4 dimension, but got array with shape (1,28,28)
147
157
  ```