Lind
@Lind (Lind Taylor)

Are you sure you want to delete the question?

If your question is resolved, you may close it.

Leaving a resolved question undeleted may help others!

We hope you find it useful!

validationに関する評価関数の値が表示されなくなった

解決したいこと

kerasでCNNのモデルを組み、評価関数を設定しました。しかし、学習用データセットの評価関数は表示されるのですが、validationデータセットでの評価関数の値が1回目の学習以降表示されません。以前は普通に表示されていたのですが、急に表示されなくなりました。解決方法はないでしょうか?

発生している問題・エラー

Epoch 1/30
10/10 [==============================] - ETA: 0s - loss: 0.8262 - accuracy: 0.6531WARNING:tensorflow:Your input ran out of data; interrupting training. Make sure that your dataset or generator can generate at least `steps_per_epoch * epochs` batches (in this case, 10 batches). You may need to use the repeat() function when building your dataset.
10/10 [==============================] - 1s 96ms/step - loss: 0.8262 - accuracy: 0.6531 - val_loss: 0.6426 - val_accuracy: 0.6667
Epoch 2/30
10/10 [==============================] - 0s 31ms/step - loss: 0.6232 - accuracy: 0.6900
Epoch 3/30
10/10 [==============================] - 0s 31ms/step - loss: 0.5937 - accuracy: 0.7200
Epoch 4/30
10/10 [==============================] - 0s 30ms/step - loss: 0.5883 - accuracy: 0.7347

該当するソースコード

from keras.models import Sequential
from keras.layers import Activation, Dense
from keras.layers import Conv2D, MaxPooling2D, Flatten
from keras.preprocessing.image import ImageDataGenerator


def main():
    model = Sequential()
    model.add(Conv2D(64, (3, 3), input_shape=(64, 64, 3)))
    model.add(Activation("relu"))
    model.add(MaxPooling2D(pool_size= (2, 2)))
    model.add(Conv2D(64, (3, 3)))
    model.add(Activation("relu"))
    model.add(MaxPooling2D(pool_size=(2, 2)))
    model.add(Flatten())
    model.add(Dense(256))
    model.add(Activation("relu"))
    model.add(Dense(2))
    model.add(Activation("softmax"))
    #model.summary()
    model.compile(
            optimizer="adam" ,
            loss="categorical_crossentropy",
            metrics=["accuracy"])
    train_datagen = ImageDataGenerator(rescale=1./255)
    test_datagen = ImageDataGenerator(rescale=1./255)
    train_generator = train_datagen.flow_from_directory(
    "/Users/tarou/Desktop/grad/trainingdataset_Ei_912_2/train",
            target_size=(64, 64),
            batch_size=10)
    validation_generator = test_datagen.flow_from_directory(
    "/Users/tarou/Desktop/grad/trainingdataset_Ei_912_2/validation",
            target_size=(64, 64),
            batch_size=10)
    model.fit_generator(
            train_generator,
            epochs=30,
            steps_per_epoch=10,
            validation_data=validation_generator,
            validation_steps=10)
    model.save("model.h5")


if __name__ == "__main__":
    main()

例)

def greet
  puts Hello World
end

自分で試したこと

0

1Answer

Your answer might help someone💌