【发布时间】:2016-08-15 08:54:07
【问题描述】:
我尝试构建一个具有 2 个隐藏层和 3 个输出类的简单 MLP。 我在模型中所做的是:
-
输入图像是 120x120 rgb 图像。展平尺寸(3 * 120 * 120)
-
2 个大小为 100 的隐藏层。
-
使用Relu激活
-
输出层有 3 个神经元
代码
def model(input, weights, biases):
l_1 = tf.add(tf.matmul(x, weights['h1']), biases['b1'])
l_1 = tf.nn.relu(l_1)
l_2 = tf.add(tf.matmul(l_1, weights['h2']), biases['b2'])
l_2 = tf.nn.relu(l_2)
out = tf.matmul(l_2, weights['out']) + biases['out']
return out
优化器
pred = model(input_batch, weights, biases)
cost = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(pred, y))
optimizer = tf.train.GradientDescentOptimizer(rate).minimize(cost)
但是该模型不起作用。准确度仅等于随机模型的准确度。 下面的例子是这个: https://github.com/aymericdamien/TensorFlow-Examples/blob/master/examples/3_NeuralNetworks/multilayer_perceptron.py
【问题讨论】:
-
你使用了多少训练数据,训练了多长时间,训练停止后的损失值是多少?
标签: machine-learning neural-network tensorflow softmax