Я новичок в TensorFlow и python. Я пытаюсь запустить код для обнаружения рака легких с использованием CNN. Вот сценарий: я пытаюсь тренировать модель CNN. Когда я использую model.fit
во время обучения, я получаю ошибку
from tflearn.layers.core import input_data, dropout, fully_connected
from tflearn.layers.conv import conv_2d, max_pool_2d
from tflearn.layers.estimator import regression
from tflearn.data_preprocessing import ImagePreprocessing
from tflearn.data_augmentation import ImageAugmentation
img_prep = ImagePreprocessing()
img_prep.add_featurewise_zero_center()
img_prep.add_featurewise_stdnorm()
img_aug = ImageAugmentation()
img_aug.add_random_flip_leftright()
img_aug.add_random_rotation(max_angle=25.)
img_aug.add_random_blur(sigma_max=3.)
network = input_data(shape=[None, 50, 50, 1],
data_preprocessing=img_prep,
data_augmentation=img_aug)
network = conv_2d(network, 50, 3, activation='relu')
network = max_pool_2d(network, 2)
network = conv_2d(network, 64, 3, activation='relu')
network = conv_2d(network, 64, 3, activation='relu')
network = max_pool_2d(network, 2)
network = fully_connected(network, 512, activation='relu')
network = dropout(network, 0.5)
network = fully_connected(network, 2, activation='softmax')
network = regression(network, optimizer='adam',
loss='categorical_crossentropy',
learning_rate=0.001)
model = tflearn.DNN(network, tensorboard_verbose=0, checkpoint_path='nodule-classifier.tfl.ckpt')
model.fit(X_train_images, Y_train_labels, n_epoch=100, shuffle=True, validation_set=(X_val_images, Y_val_labels),
show_metric=True, batch_size=96, snapshot_epoch=True,
run_id='noduleclassifier')
model.save("nodule-classifier.tfl")
print("Network trained and saved as nodule-classifier.tfl!")
Я пытаюсь обучить модель CNN. Когда я использую model.fit
во время обучения, я получаю сообщение об ошибке ->
ValueErrorTraceback (most recent call last)
<ipython-input-60-e6a88471dbf1> in <module>()
5 model.fit(X_train_images, Y_train_labels, n_epoch=100, shuffle=True, validation_set=(X_val_images, Y_val_labels),
6 show_metric=True, batch_size=96, snapshot_epoch=True,
----> 7 run_id='noduleclassifier')
8
9 # Save model when training is complete to a file
-----------------------------------------------------------------------------
/tensorflow-1.15.2/python2.7/tensorflow_core/python/client/session.pyc in _run(self, handle, fetches, feed_dict, options, run_metadata)
1154 'Cannot feed value of shape %r for Tensor %r, '
1155 'which has shape %r' %
-> 1156 (np_val.shape, subfeed_t.name, str(subfeed_t.get_shape())))
1157 if not self.graph.is_feedable(subfeed_t):
1158 raise ValueError('Tensor %s may not be fed.' % subfeed_t)
ValueError: Cannot feed value of shape (96, 50, 50) for Tensor u'InputData/X:0', which has shape '(?, 50, 50, 1)'
error_image
ссылка на оригинальный код -> ссылка
Может кто-нибудь помочь мне решить эту проблему, пожалуйста?