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

回答編集履歴

2

指摘を受けて修正

2018/06/08 07:46

投稿

wakame
wakame

スコア1170

answer CHANGED
@@ -40,7 +40,7 @@
40
40
  x = numpy.array(img, dtype=numpy.float32)
41
41
  x = x / 255.
42
42
  x = x[None, ...]
43
- print(img.shape)
43
+ print(x.shape)
44
44
  # (1, 28, 28, 3)
45
45
  # RGBScaleで読み込んだためchannelが3になっていますね
46
46
  x = numpy.reshape(x, [28,28,1])
@@ -54,9 +54,9 @@
54
54
  filepath = "/Users/atg/work/python/tensorflow/jupyter/mnist_test_data/img_1.jpg"
55
55
  img = Image.open(filepath).convert('L') ## Gray->L, RGB->RGB
56
56
  x = numpy.array(img, dtype=numpy.float32)
57
- x = img.reshape((28, 28, 1))
57
+ x = x.reshape((28, 28, 1))
58
58
  x = x / 255.
59
59
  x = x[None, ...]
60
- print(img.shape)
60
+ print(x.shape)
61
61
  # (1, 28, 28, 1)
62
62
  ```

1

日本語がおかしい部分を修正

2018/06/08 07:45

投稿

wakame
wakame

スコア1170

answer CHANGED
@@ -29,7 +29,7 @@
29
29
  input_shape=input_shape))
30
30
  ```
31
31
 
32
- 予測時画像の前処理のコードにコメントをつけてみました。
32
+ 予測時画像の前処理のコードにコメントをつけてみました。
33
33
  ```python
34
34
  # predict
35
35
  filepath = "/Users/atg/work/python/tensorflow/jupyter/mnist_test_data/img_1.jpg"