前提・実現したいこと
https://teratail.com/questions/247844
上のリンクのgoogle colaboratoryのgpuの設定を変えたのですが,学習が終わりません...
発生してる問題の解決策(一般論でも構いません!)をいくつかご教授頂ければ幸いです.
発生している問題・エラーメッセージ
epochが1/30から30分以上経っても進みません
該当のソースコード
Python
1import tensorflow as tf 2import numpy as np 3input_tensor = tf.keras.Input(shape=(224, 224, 3)) 4model=tf.keras.applications.VGG19(include_top=False, 5 weights='imagenet',input_tensor=input_tensor) 6x = model.output 7x = tf.keras.layers.GlobalAveragePooling2D()(x) 8x = tf.keras.layers.Dense(1024, activation='relu')(x) 9predictions = tf.keras.layers.Dense(2, activation='softmax')(x) 10model = tf.keras.Model(inputs=model.input, outputs=predictions) 11for layer in model.layers: 12 layer.trainable = False 13model.compile(tf.keras.optimizers.SGD(lr=0.0001, momentum=0.9), loss='categorical_crossentropy',metrics=['accuracy']) 14 15model.summary() 16 17datagen = tf.keras.preprocessing.image.ImageDataGenerator() 18train_datagen = tf.keras.preprocessing.image.ImageDataGenerator( 19 'train_dir', 20 shear_range=0.2, 21 zoom_range=0.2, 22 horizontal_flip=True, 23 rotation_range=10) 24 25test_datagen = tf.keras.preprocessing.image.ImageDataGenerator() 26 27validation_generator = test_datagen.flow_from_directory( 28 directory=test_dir, 29 target_size=(224, 224), 30 batch_size=16, 31 class_mode='binary', 32 shuffle=True) 33 34train_generator = train_datagen.flow_from_directory( 35 directory=train_dir, 36 target_size=(224, 224), 37 batch_size=16, 38 class_mode='binary', 39 shuffle=True 40) 41 42hist = model.fit_generator(train_generator, 43 steps_per_epoch=1000, 44 epochs=30, 45 verbose=1, 46 validation_data=validation_generator, 47 validation_steps=250 48 )
model
1input_1 (InputLayer) [(None, 224, 224, 3)] 0 2_________________________________________________________________ 3block1_conv1 (Conv2D) (None, 224, 224, 64) 1792 4_________________________________________________________________ 5block1_conv2 (Conv2D) (None, 224, 224, 64) 36928 6_________________________________________________________________ 7block1_pool (MaxPooling2D) (None, 112, 112, 64) 0 8_________________________________________________________________ 9block2_conv1 (Conv2D) (None, 112, 112, 128) 73856 10_________________________________________________________________ 11block2_conv2 (Conv2D) (None, 112, 112, 128) 147584 12_________________________________________________________________ 13block2_pool (MaxPooling2D) (None, 56, 56, 128) 0 14_________________________________________________________________ 15block3_conv1 (Conv2D) (None, 56, 56, 256) 295168 16_________________________________________________________________ 17block3_conv2 (Conv2D) (None, 56, 56, 256) 590080 18_________________________________________________________________ 19block3_conv3 (Conv2D) (None, 56, 56, 256) 590080 20_________________________________________________________________ 21block3_conv4 (Conv2D) (None, 56, 56, 256) 590080 22_________________________________________________________________ 23block3_pool (MaxPooling2D) (None, 28, 28, 256) 0 24_________________________________________________________________ 25block4_conv1 (Conv2D) (None, 28, 28, 512) 1180160 26_________________________________________________________________ 27block4_conv2 (Conv2D) (None, 28, 28, 512) 2359808 28_________________________________________________________________ 29block4_conv3 (Conv2D) (None, 28, 28, 512) 2359808 30_________________________________________________________________ 31block4_conv4 (Conv2D) (None, 28, 28, 512) 2359808 32_________________________________________________________________ 33block4_pool (MaxPooling2D) (None, 14, 14, 512) 0 34_________________________________________________________________ 35block5_conv1 (Conv2D) (None, 14, 14, 512) 2359808 36_________________________________________________________________ 37block5_conv2 (Conv2D) (None, 14, 14, 512) 2359808 38_________________________________________________________________ 39block5_conv3 (Conv2D) (None, 14, 14, 512) 2359808 40_________________________________________________________________ 41block5_conv4 (Conv2D) (None, 14, 14, 512) 2359808 42_________________________________________________________________ 43block5_pool (MaxPooling2D) (None, 7, 7, 512) 0 44_________________________________________________________________ 45global_average_pooling2d (Gl (None, 512) 0 46_________________________________________________________________ 47dense (Dense) (None, 1024) 525312 48_________________________________________________________________ 49dense_1 (Dense) (None, 2) 2050 50================================================================= 51Total params: 20,551,746 52Trainable params: 0 53Non-trainable params: 20,551,746 54_________________________________________________________________
補足情報(FW/ツールのバージョンなど)
Google Colaboratory上で実行しています,GPUで実行していますが,2時間経っても進みません...
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2020/03/18 06:35
2020/03/18 06:51