質問編集履歴
5
結果行変更
title
CHANGED
File without changes
|
body
CHANGED
@@ -211,19 +211,19 @@
|
|
211
211
|
Traceback (most recent call last):
|
212
212
|
File "cnn_image.py", line 53, in <module>
|
213
213
|
model.fit(train_images, train_labels, epochs=5)
|
214
|
-
File "C:\Users\
|
214
|
+
File "C:\Users\anaconda3\envs\tensorflow-cpu\lib\site-packages\tensorflow\python\keras\engine\training.py", line 1100, in fit
|
215
215
|
tmp_logs = self.train_function(iterator)
|
216
|
-
File "C:\Users\
|
216
|
+
File "C:\Users\anaconda3\envs\tensorflow-cpu\lib\site-packages\tensorflow\python\eager\def_function.py", line 828, in __call__
|
217
217
|
result = self._call(*args, **kwds)
|
218
|
-
File "C:\Users\
|
218
|
+
File "C:\Users\anaconda3\envs\tensorflow-cpu\lib\site-packages\tensorflow\python\eager\def_function.py", line 888, in _call
|
219
219
|
return self._stateless_fn(*args, **kwds)
|
220
|
-
File "C:\Users\
|
220
|
+
File "C:\Users\anaconda3\envs\tensorflow-cpu\lib\site-packages\tensorflow\python\eager\function.py", line 2942, in __call__
|
221
221
|
return graph_function._call_flat(
|
222
|
-
File "C:\Users\
|
222
|
+
File "C:\Users\anaconda3\envs\tensorflow-cpu\lib\site-packages\tensorflow\python\eager\function.py", line 1918, in _call_flat
|
223
223
|
return self._build_call_outputs(self._inference_function.call(
|
224
|
-
File "C:\Users\
|
224
|
+
File "C:\Users\anaconda3\envs\tensorflow-cpu\lib\site-packages\tensorflow\python\eager\function.py", line 555, in call
|
225
225
|
outputs = execute.execute(
|
226
|
-
File "C:\Users\
|
226
|
+
File "C:\Users\anaconda3\envs\tensorflow-cpu\lib\site-packages\tensorflow\python\eager\execute.py", line 59, in quick_execute
|
227
227
|
tensors = pywrap_tfe.TFE_Py_Execute(ctx._handle, device_name, op_name,
|
228
228
|
tensorflow.python.framework.errors_impl.InvalidArgumentError: logits and labels must have the same first dimension, got logits shape [10,10] and labels shape [100]
|
229
229
|
[[node sparse_categorical_crossentropy/SparseSoftmaxCrossEntropyWithLogits/SparseSoftmaxCrossEntropyWithLogits (defined at cnn_image.py:53) ]] [Op:__inference_train_
|
4
回答に対して試した結果を更新
title
CHANGED
File without changes
|
body
CHANGED
@@ -125,6 +125,12 @@
|
|
125
125
|
|
126
126
|
```
|
127
127
|
```python
|
128
|
+
# TensorFlow と tf.keras のインポート
|
129
|
+
import tensorflow as tf
|
130
|
+
from tensorflow import keras
|
131
|
+
|
132
|
+
# ヘルパーライブラリのインポート
|
133
|
+
import numpy as np
|
128
134
|
import matplotlib.pyplot as plt
|
129
135
|
|
130
136
|
print(tf.__version__)
|
@@ -133,10 +139,12 @@
|
|
133
139
|
|
134
140
|
#(train_images, train_labels), (test_images, test_labels) = mnist.load_data()
|
135
141
|
import image_dataset
|
136
|
-
train_images ,train_labels, test_images ,test_labels = image_dataset.make('C:dataset',img_size = 32, train_num=10000 , test_num =1000)
|
142
|
+
train_images ,train_labels, test_images ,test_labels = image_dataset.make('C:/Users/cv/dataset',img_size = 32, train_num=10000 , test_num =1000)
|
137
143
|
|
138
144
|
train_images.shape
|
139
145
|
|
146
|
+
print(train_images.shape, train_labels.shape)
|
147
|
+
|
140
148
|
#plt.figure()
|
141
149
|
#plt.imshow(train_images[0], cmap='gray')
|
142
150
|
#plt.colorbar()
|
@@ -160,7 +168,6 @@
|
|
160
168
|
test_images = test_images / 255.0
|
161
169
|
|
162
170
|
model = keras.Sequential([
|
163
|
-
keras.layers.Flatten(input_shape=(28, 28)),
|
164
171
|
keras.layers.Dense(128, activation='relu'),
|
165
172
|
keras.layers.Dense(10, activation='softmax')
|
166
173
|
])
|
@@ -181,45 +188,51 @@
|
|
181
188
|
print("end")
|
182
189
|
|
183
190
|
```
|
191
|
+
Flatten実行の行を消して実行した結果
|
184
|
-
```
|
192
|
+
```
|
185
|
-
PS C:\Users> python cnn_test2.py
|
186
|
-
2021-02-
|
193
|
+
2021-02-17 10:05:53.420778: W tensorflow/stream_executor/platform/default/dso_loader.cc:60] Could not load dynamic library 'cudart64_110.dll'; dlerror: cudart64_110.dll not f
|
187
194
|
ound
|
188
|
-
2021-02-
|
195
|
+
2021-02-17 10:05:53.428672: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
|
196
|
+
2.4.1
|
197
|
+
0read complete ,1 pictures exit
|
189
198
|
~中略~
|
199
|
+
(10, 3072) (10, 10)
|
200
|
+
2021-02-17 10:05:59.694157: I tensorflow/compiler/jit/xla_cpu_device.cc:41] Not creating XLA devices, tf_xla_enable_xla_devices not set
|
190
|
-
|
201
|
+
2021-02-17 10:05:59.706703: W tensorflow/stream_executor/platform/default/dso_loader.cc:60] Could not load dynamic library 'nvcuda.dll'; dlerror: nvcuda.dll not found
|
202
|
+
2021-02-17 10:05:59.718986: W tensorflow/stream_executor/cuda/cuda_driver.cc:326] failed call to cuInit: UNKNOWN ERROR (303)
|
203
|
+
2021-02-17 10:05:59.799102: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:169] retrieving CUDA diagnostic information for host: CVPC-0164
|
204
|
+
2021-02-17 10:05:59.806406: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:176] hostname: CVPC-0164
|
191
|
-
|
205
|
+
2021-02-17 10:05:59.811840: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use t
|
206
|
+
he following CPU instructions in performance-critical operations: AVX2
|
207
|
+
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
|
208
|
+
2021-02-17 10:05:59.820411: I tensorflow/compiler/jit/xla_gpu_device.cc:99] Not creating XLA devices, tf_xla_enable_xla_devices not set
|
209
|
+
2021-02-17 10:06:00.102449: I tensorflow/compiler/mlir/mlir_graph_optimization_pass.cc:116] None of the MLIR optimization passes are enabled (registered 2)
|
210
|
+
Epoch 1/5
|
192
211
|
Traceback (most recent call last):
|
193
|
-
File "
|
212
|
+
File "cnn_image.py", line 53, in <module>
|
194
213
|
model.fit(train_images, train_labels, epochs=5)
|
195
|
-
File "C:\Users\anaconda3\envs\tensorflow-cpu\lib\site-packages\tensorflow\python\keras\engine\training.py", line 1100, in fit
|
214
|
+
File "C:\Users\cv\anaconda3\envs\tensorflow-cpu\lib\site-packages\tensorflow\python\keras\engine\training.py", line 1100, in fit
|
196
215
|
tmp_logs = self.train_function(iterator)
|
197
|
-
File "C:\Users\anaconda3\envs\tensorflow-cpu\lib\site-packages\tensorflow\python\eager\def_function.py", line 828, in __call__
|
216
|
+
File "C:\Users\cv\anaconda3\envs\tensorflow-cpu\lib\site-packages\tensorflow\python\eager\def_function.py", line 828, in __call__
|
198
217
|
result = self._call(*args, **kwds)
|
199
|
-
File "C:\Users\anaconda3\envs\tensorflow-cpu\lib\site-packages\tensorflow\python\eager\def_function.py", line
|
218
|
+
File "C:\Users\cv\anaconda3\envs\tensorflow-cpu\lib\site-packages\tensorflow\python\eager\def_function.py", line 888, in _call
|
219
|
+
return self._stateless_fn(*args, **kwds)
|
220
|
+
File "C:\Users\cv\anaconda3\envs\tensorflow-cpu\lib\site-packages\tensorflow\python\eager\function.py", line 2942, in __call__
|
221
|
+
return graph_function._call_flat(
|
222
|
+
File "C:\Users\cv\anaconda3\envs\tensorflow-cpu\lib\site-packages\tensorflow\python\eager\function.py", line 1918, in _call_flat
|
200
|
-
self.
|
223
|
+
return self._build_call_outputs(self._inference_function.call(
|
201
|
-
File "C:\Users\anaconda3\envs\tensorflow-cpu\lib\site-packages\tensorflow\python\eager\
|
224
|
+
File "C:\Users\cv\anaconda3\envs\tensorflow-cpu\lib\site-packages\tensorflow\python\eager\function.py", line 555, in call
|
202
|
-
self._stateful_fn._get_concrete_function_internal_garbage_collected( # pylint: disable=protected-access
|
203
|
-
File "C:\Users\anaconda3\envs\tensorflow-cpu\lib\site-packages\tensorflow\python\eager\function.py", line 2969, in _get_concrete_function_internal_garbage_collected
|
204
|
-
graph_function, _ = self._maybe_define_function(args, kwargs)
|
205
|
-
File "C:\Users\anaconda3\envs\tensorflow-cpu\lib\site-packages\tensorflow\python\eager\function.py", line 3361, in _maybe_define_function
|
206
|
-
graph_function = self._create_graph_function(args, kwargs)
|
207
|
-
File "C:\Users\anaconda3\envs\tensorflow-cpu\lib\site-packages\tensorflow\python\eager\function.py", line 3196, in _create_graph_function
|
208
|
-
func_graph_module.func_graph_from_py_func(
|
209
|
-
File "C:\Users\anaconda3\envs\tensorflow-cpu\lib\site-packages\tensorflow\python\framework\func_graph.py", line 990, in func_graph_from_py_func
|
210
|
-
|
225
|
+
outputs = execute.execute(
|
211
|
-
File "C:\Users\anaconda3\envs\tensorflow-cpu\lib\site-packages\tensorflow\python\eager\
|
226
|
+
File "C:\Users\cv\anaconda3\envs\tensorflow-cpu\lib\site-packages\tensorflow\python\eager\execute.py", line 59, in quick_execute
|
212
|
-
|
227
|
+
tensors = pywrap_tfe.TFE_Py_Execute(ctx._handle, device_name, op_name,
|
228
|
+
tensorflow.python.framework.errors_impl.InvalidArgumentError: logits and labels must have the same first dimension, got logits shape [10,10] and labels shape [100]
|
213
|
-
|
229
|
+
[[node sparse_categorical_crossentropy/SparseSoftmaxCrossEntropyWithLogits/SparseSoftmaxCrossEntropyWithLogits (defined at cnn_image.py:53) ]] [Op:__inference_train_
|
214
|
-
raise e.ag_error_metadata.to_exception(e)
|
215
|
-
|
230
|
+
function_528]
|
216
231
|
|
217
|
-
|
232
|
+
Function call stack:
|
218
|
-
|
233
|
+
train_function
|
219
234
|
|
220
|
-
ValueError: Input 0 of layer dense is incompatible with the layer: expected axis -1 of input shape to have value 784 but received input with shape (None, 2352)
|
221
|
-
|
222
|
-
PS C:\Users>
|
235
|
+
PS C:\Users\cv>
|
223
236
|
```
|
224
237
|
print(train_images.shape, train_labels.shape)の結果
|
225
238
|
```
|
3
書式の改善
title
CHANGED
File without changes
|
body
CHANGED
@@ -221,7 +221,7 @@
|
|
221
221
|
|
222
222
|
PS C:\Users>
|
223
223
|
```
|
224
|
-
print(train_images.shape, train_labels.shape)
|
224
|
+
print(train_images.shape, train_labels.shape)の結果
|
225
225
|
```
|
226
226
|
(10, 2352) (10, 10)
|
227
227
|
```
|
2
情報追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -221,8 +221,8 @@
|
|
221
221
|
|
222
222
|
PS C:\Users>
|
223
223
|
```
|
224
|
-
|
225
|
-
|
224
|
+
print(train_images.shape, train_labels.shape)`の結果
|
225
|
+
```
|
226
226
|
(10, 2352) (10, 10)
|
227
227
|
```
|
228
228
|
python3.7
|
1
print(train_images.shape, train_labels.shape)`の結果を追記しました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -221,5 +221,9 @@
|
|
221
221
|
|
222
222
|
PS C:\Users>
|
223
223
|
```
|
224
|
+
|
225
|
+
```print(train_images.shape, train_labels.shape)`の結果
|
226
|
+
(10, 2352) (10, 10)
|
227
|
+
```
|
224
228
|
python3.7
|
225
229
|
Tensorflow2.4.1
|