x_image = tf.reshape(x, [-1, IMG_SIZE, IMG_SIZE, 3]) # 128
W_conv1 = tf.get_variable("W_conv1", shape=[3, 3, 3, 64], initializer=xavier())
b_conv1 = tf.get_variable('b_conv1', [1, 1, 1, 64])
h_conv1 = tf.nn.relu(conv2d(x_image, W_conv1) + b_conv1)
h_pool1 = max_pool_2x2(h_conv1) # 64
W_conv2 = tf.get_variable("W_conv2", shape=[3, 3, 64, 128], initializer=xavier())
b_conv2 = tf.get_variable('b_conv2', [1, 1, 1, 128])
h_conv2 = tf.nn.relu(conv2d(h_pool1, W_conv2) + b_conv2)
h_pool2 = max_pool_2x2(h_conv2) # 32
W_conv3 = tf.get_variable("W_conv3", shape=[3, 3, 128, 256], initializer=xavier())
b_conv3 = tf.get_variable('b_conv3', [1, 1, 1, 256])
h_conv3 = tf.nn.relu(conv2d(h_pool2, W_conv3) + b_conv3)
h_pool3 = max_pool_2x2(h_conv3) # 16
W_conv4 = tf.get_variable("W_conv4", shape=[3, 3, 256, 512], initializer=xavier())
b_conv4 = tf.get_variable('b_conv4', [1, 1, 1, 512])
h_conv4 = tf.nn.relu(conv2d(h_pool3, W_conv4) + b_conv4)
h_pool4 = max_pool_2x2(h_conv4) # 8
W_conv5 = tf.get_variable("W_conv5", shape=[3, 3, 512, 512], initializer=xavier())
b_conv5 = tf.get_variable('b_conv5', [1, 1, 1, 512])
h_conv5 = tf.nn.relu(conv2d(h_pool4, W_conv5) + b_conv5)
h_pool5 = max_pool_2x2(h_conv5) # 4
h_pool5_flat = tf.reshape(h_pool5, [-1, 4 * 4 * 512])
W_fc1 = tf.get_variable("W_fc1", shape=[4 * 4 * 512, 4096], initializer=xavier())
b_fc1 = tf.get_variable('b_fc1', [4096], initializer=init_ops.zeros_initializer())
h_fc1 = tf.nn.relu(tf.matmul(h_pool5_flat, W_fc1) + b_fc1)
keep_prob = tf.placeholder(tf.float32)
h_fc1_drop = tf.nn.dropout(h_fc1, keep_prob)
W_fcO = tf.get_variable("W_fcO", shape=[4096, 2], initializer=xavier())
b_fcO = tf.get_variable('b_fcO', [2], initializer=init_ops.zeros_initializer())
logits = tf.matmul(h_fc1_drop, W_fcO) + b_fcO
y_conv = tf.nn.softmax(logits)
cross_entropy = loss_ops.softmax_cross_entropy(logits, y_)
train_step = tf.train.AdamOptimizer(0.0005).minimize(cross_entropy)
self.results = predictions = tf.argmax(y_conv, 1)
self.probabilities = y_conv
correct_prediction = tf.equal(predictions, tf.argmax(y_, 1))
accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))
我只有2节课。我的批次是32K阳性和32K阴性图像(128x128)。我跑了80个纪元。测试神经网络的正/负是非常有希望的。我在我的电脑上运行了另一批测试。跑了500张负面图片,误报率为8%,200张正面图像,假阴性率为9%。
当我尝试检查概率时出现问题。 Softmax每个类主要返回1.0或0.0。不应该像0.745 / 0.255这样的东西。
即使它很好地对图像进行分类,softmax也会返回过于密集的结果。我的错误在哪里?