0
0 комментариев

При обучении нейронной сети на вход подаются изображения в виде массива и правильные ответы. Само обучение срабатывает мгновенно и результат для всех данных в результате предсказания одинаковый.
Фрагмент данных, которые подаются как правильные:

[ 0.  0.  1.]
 [ 0.  0.  1.]
 [ 1.  0.  0.]
 [ 0.  0.  1.]
 [ 1.  0.  0.]

Фрагмент массивов с изображениями:

[[ 0.          0.          0.         ...,  0.          0.          0.        ]
 [ 0.          0.          0.         ...,  0.          0.          0.00392157]
 [ 0.          0.          0.         ...,  0.          0.          0.        ]
 ...,
 [ 0.00392157  0.          1.         ...,  0.          0.          0.        ]
 [ 0.          0.          0.00784314 ...,  0.          0.          0.        ]
 [ 0.          0.          0.         ...,  0.          0.          0.        ]]

Работа программы и предсказания:

Epoch 17/20
212/212 [==============================] - 0s - loss: 0.9579 - acc: 0.5047 - val_loss: 1.0571 - val_acc: 0.4953
Epoch 18/20
212/212 [==============================] - 0s - loss: 0.9437 - acc: 0.5047 - val_loss: 1.0584 - val_acc: 0.4953
Epoch 19/20
212/212 [==============================] - 0s - loss: 0.9352 - acc: 0.5047 - val_loss: 1.0588 - val_acc: 0.4953
Epoch 20/20
212/212 [==============================] - 0s - loss: 0.9420 - acc: 0.5047 - val_loss: 1.0583 - val_acc: 0.4953
 
Total time taken to train model: 4.23444890976 seconds
 
Evaluation of model on test holdout set:
212/212 [==============================] - 0s
[[ 0.30997425  0.32370323  0.36632255]]
[[ 0.31032962  0.32383287  0.36583754]]
[[ 0.30994558  0.32400697  0.36604744]]
[[ 0.30967158  0.32383308  0.36649528]]
[[ 0.30953971  0.32438737  0.36607292]]
[[ 0.30939212  0.3241998   0.36640811]]
[[ 0.30983475  0.32379121  0.36637402]]
[[ 0.30952132  0.32428694  0.36619174]]
[[ 0.30997089  0.32373276  0.36629626]]
[[ 0.31023106  0.32390219  0.36586678]]
[[ 0.30982301  0.32382965  0.36634725]]
[[ 0.31022772  0.32347488  0.36629739]]
[[ 0.30987772  0.32441998  0.3657023 ]]
[[ 0.30946305  0.32396272  0.36657417]]

Часть программы:

# Load training data, unpacking what's in the saved .npz files.
image_array = np.zeros((1, 38400))
label_array = np.zeros((1, 3), 'float')
training_data = glob.glob('training_data_temp/*.npz')
 
for single_npz in training_data:
    with np.load(single_npz) as data:
        train_temp = data['train']
        train_labels_temp = data['train_labels']
    image_array = np.vstack((image_array, train_temp))
    label_array = np.vstack((label_array, train_labels_temp))
 
X = image_array[1:, :]
y = label_array[1:, :]
 
# Normalize from 0 to 1
X = X / 255.
 
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.50)
 
# Get start time of Training
time_training_start = time.time()
 
model = Sequential()
model.add(Dense(30, input_dim=38400, init='uniform'))
model.add(Dropout(0.2))
model.add(Activation('relu'))
model.add(Dense(3, init='uniform'))
model.add(Activation('softmax'))
 
 
sgd = SGD(lr=0.01, decay=1e-6, momentum=0.9, nesterov=True)
model.compile(loss='categorical_crossentropy',
              optimizer=sgd,
              metrics=['accuracy'])
 
# Fit the model
model.fit(X_train, y_train,
          nb_epoch=20,
          batch_size=1000,
          validation_data=(X_test, y_test))

Изменен статус публикации
Добавить комментарий