Я пытаюсь построить CNN, используя tflearn
, используя следующий код
train_images, train_labels, test_images, test_labels = load_dataset()
convnet = input_data(shape=[None, 28, 28, 1], name='input')
convnet = conv_2d(convnet, 32, 2, activation='relu')
convnet = max_pool_2d(convnet, 2)
convnet = conv_2d(convnet, 64, 2, activation='relu')
convnet = max_pool_2d(convnet, 2)
convnet = fully_connected(convnet, 1024, activation='relu')
convnet = dropout(convnet, 0.8)
convnet = fully_connected(convnet, 24, activation='softmax')
convnet = regression(convnet, optimizer='adam', learning_rate=0.01, loss='categorical_crossentropy')
model = tflearn.DNN(convnet)
model.fit(train_images, train_labels, n_epoch=30,
validation_set=(test_images, test_labels),
snapshot_step=500, show_metric=True, run_id='characterOCR')
model.save('CNN.model')
Набор данных был преобразован в следующую форму
def load_mnist_images(filename):
with gzip.open(filename, 'rb') as f:
data = np.frombuffer(f.read(), np.uint8, offset=16)
data = data.reshape(-1, 28, 28, 1)
return data
Это мой набор данных, но я построилэто основано на структуре MNIST, теперь я получаю следующую ошибку:
Traceback (most recent call last):
File "/home/hassan/JPG-PNG-to-MNIST-NN-Format/CNN_network.py", line 56, in <module>
snapshot_step=500, show_metric=True, run_id='characterOCR')
File "/home/hassan/anaconda3/envs/object-detection/lib/python3.7/site-packages/tflearn/models/dnn.py", line 216, in fit
callbacks=callbacks)
File "/home/hassan/anaconda3/envs/object-detection/lib/python3.7/site-packages/tflearn/helpers/trainer.py", line 339, in fit
show_metric)
File "/home/hassan/anaconda3/envs/object-detection/lib/python3.7/site-packages/tflearn/helpers/trainer.py", line 818, in _train
feed_batch)
File "/home/hassan/anaconda3/envs/object-detection/lib/python3.7/site-packages/tensorflow/python/client/session.py", line 950, in run
run_metadata_ptr)
File "/home/hassan/anaconda3/envs/object-detection/lib/python3.7/site-packages/tensorflow/python/client/session.py", line 1149, in _run
str(subfeed_t.get_shape())))
ValueError: Cannot feed value of shape (64,) for Tensor 'TargetsData/Y:0', which has shape '(?, 24)'
У кого-нибудь есть решение?