DNN在不同的计算机上具有不同的结果

时间:2018-10-24 19:52:24

标签: tensor tflearn

我正在训练DNN进行短语分类。当我在PC上进行训练时(2.50 GHz×4的Intel®Core™i7-6500U CPU×4和GeForce 930M / PCIe / SSE2),它将获得良好的结果(正确性的95.5%)。但是,当我尝试在Docker容器上运行和训练它时,每次我训练网络时都会得到不同的结果。

模型如下

training = np.array(training)

# create train and test lists
train_x = list(training[:,0])
train_y = list(training[:,1])

#tf.reset_default_graph()
tflearn.init_graph(seed=0, gpu_memory_fraction=1)

# Build fully connected neural network
net = tflearn.input_data(shape=[None, len(train_x[0])])
net = tflearn.fully_connected(net, 48)
net = tflearn.fully_connected(net, 48)
net = tflearn.fully_connected(net, len(train_y[0]), activation='softmax')
net = tflearn.regression(net, learning_rate=0.001, loss='categorical_crossentropy')


# Define model and setup tensorboard
__location__ = os.path.realpath(os.path.join(os.getcwd(), os.path.dirname(__file__)))


model = tflearn.DNN(net, tensorboard_dir='tflearn_logs', tensorboard_verbose=3)
model.fit(train_x, train_y, n_epoch=200, batch_size=3, show_metric=True)
model.save('model-MyNet.tflearn')
model.load(os.path.join(__location__,'model-MyNet.tflearn'))


# save all of our data structures
import pickle
pickle.dump( {'words':words, 'classes':classes, 'train_x':train_x, 'train_y':train_y}, open( "training_data-MyNet", "wb" ) )

0 个答案:

没有答案