我目前使用 keras 的 vgg16 進行建模,但是每次結果都不一樣,
即使我設定 seed,shuffle 也設 false
code 如下,想問問看有沒有什麼解決方法,
我上網 google ,有可能是因為 GPU 運算的關係? 那要如何解?
謝謝
PS: 環境
ubuntu 16.04
python3
gtx-1070
model_vgg16_conv = VGG16(weights=None, include_top=False)
input = Input(shape=(rows,cols,3),name = 'image_input')
output_vgg16_conv = model_vgg16_conv(input)
x = Flatten(name='flatten')(output_vgg16_conv)
x = Dense(1024, activation='relu', name='fc1')(x)
x = Dense(1024, activation='relu', name='fc2')(x)
x = Dense(2, activation='softmax', name='predictions')(x)
model = Model(input=input, output=x)
sgd = SGD(lr=1e-4, momentum=0.2, nesterov=True)
model.compile(sgd, loss='binary_crossentropy')
random.seed(100)
set_random_seed(100)
np.random.seed(1337)
model.fit(sub_train_x,
sub_train_y,
batch_size=64,
epochs=2,
verbose=1,
#validation_split=0.2,
shuffle=False)