CNNをもとに機械学習を行っているのですが、サンプル数は683と出ているのですが、機械学習の際に使われている数が22となっています。
この原因が分かる方がいらっしゃれば是非教えていただきたいです。
該当のソースコード
CNNを構築
model = Sequential()
model.add(Conv2D(32, (3, 3), padding='same',input_shape=X_train.shape[1:]))
model.add(Activation('relu'))
model.add(Conv2D(32, (3, 3)))
model.add(Activation('relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Dropout(0.25))
model.add(Conv2D(64, (3, 3), padding='same'))
model.add(Activation('relu'))
model.add(Conv2D(64, (3, 3)))
model.add(Activation('relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Dropout(0.25))
model.add(Flatten())
model.add(Dense(512))
model.add(Activation('relu'))
model.add(Dropout(0.5))
model.add(Dense(3))
model.add(Activation('softmax'))
model.summary()
コンパイル
model.compile(loss='categorical_crossentropy',optimizer='SGD',metrics=['accuracy'])
print(len(X_train))
print(len(y_train))
print(len(X_test))
print(len(y_test))
history = model.fit(X_train, y_train, epochs=5)
#出力結果
Model: "sequential"
Layer (type) Output Shape Param #
conv2d (Conv2D) (None, 100, 100, 32) 896
activation (Activation) (None, 100, 100, 32) 0
conv2d_1 (Conv2D) (None, 98, 98, 32) 9248
activation_1 (Activation) (None, 98, 98, 32) 0
max_pooling2d (MaxPooling2D) (None, 49, 49, 32) 0
dropout (Dropout) (None, 49, 49, 32) 0
conv2d_2 (Conv2D) (None, 49, 49, 64) 18496
activation_2 (Activation) (None, 49, 49, 64) 0
conv2d_3 (Conv2D) (None, 47, 47, 64) 36928
activation_3 (Activation) (None, 47, 47, 64) 0
max_pooling2d_1 (MaxPooling2 (None, 23, 23, 64) 0
dropout_1 (Dropout) (None, 23, 23, 64) 0
flatten (Flatten) (None, 33856) 0
dense (Dense) (None, 512) 17334784
activation_4 (Activation) (None, 512) 0
dropout_2 (Dropout) (None, 512) 0
dense_1 (Dense) (None, 3) 1539
=================================================================
Total params: 17,401,891
Trainable params: 17,401,891
Non-trainable params: 0
683
683
171
171
Epoch 1/5
22/22 [==============================] - 29s 1s/step - loss: 1.1049 - accuracy: 0.3704
Epoch 2/5
22/22 [==============================] - 28s 1s/step - loss: 1.0947 - accuracy: 0.3953
Epoch 3/5
22/22 [==============================] - 29s 1s/step - loss: 1.0884 - accuracy: 0.4158
Epoch 4/5
22/22 [==============================] - 31s 1s/step - loss: 1.0827 - accuracy: 0.4085
Epoch 5/5
22/22 [==============================] - 40s 2s/step - loss: 1.0843 - accuracy: 0.4114
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2020/11/21 08:20