回答編集履歴
2
指摘を受けて修正
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(
|
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 =
|
57
|
+
x = x.reshape((28, 28, 1))
|
58
58
|
x = x / 255.
|
59
59
|
x = x[None, ...]
|
60
|
-
print(
|
60
|
+
print(x.shape)
|
61
61
|
# (1, 28, 28, 1)
|
62
62
|
```
|
1
日本語がおかしい部分を修正
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"
|