我目前使用 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)