作者f496328mm (123)
看板Python
标题[问题] Keras 每次结果不同
时间Wed Sep 6 13:15:49 2017
我目前使用 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)
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 114.36.50.200
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/Python/M.1504674952.A.F26.html
谢谢
我也有找到这篇,不过还是不太行,发文者最後也没有解决
其实网路上很多讨论,大家都有类似的问题,然後解决方法都不同@@
目前在一个一个测试中,不过情况不乐观,
希望有相关经验的高手,分享经验 > <
※ 编辑: f496328mm (114.36.50.200), 09/06/2017 19:01:29
2F:→ hl4: 他有找到可行的做法阿,只是要重开 ipynb 而已 09/06 20:53