Почему эта модель нейронной сети работает плохо? - PullRequest
0 голосов
/ 07 июля 2019

Я пытаюсь создать сверточную нейронную сеть, но по какой-то причине после тренировки она абсолютно бесполезна.

Она всегда дает такие результаты. неизвестно (оценка = 1,00000) тест (оценка = 0,00000)

Может быть, я неправильно построил модель.

Я бы хотел знать. Что я делаю не так? Спасибо.

def create_conv_model(fingerprint_input, model_settings, is_training):

  if is_training:
    dropout_prob = tf.placeholder(tf.float32, name='dropout_prob')

  weights = {
    'wc1': tf.Variable(tf.random_normal([3, 3, 1, 8])),
    'wc2': tf.Variable(tf.random_normal([3, 3, 8, 16])),
    'wc3': tf.Variable(tf.random_normal([1, 1, 16, 16])),
    'wc4': tf.Variable(tf.random_normal([3, 3, 16, 32])),
    'wc5': tf.Variable(tf.random_normal([1, 1, 32, 32])),
    'wc6': tf.Variable(tf.random_normal([3, 3, 32, 32])),
    'wc7': tf.Variable(tf.random_normal([1, 1, 32, 32]))
  }

  biases = {
    'bc1': tf.Variable(tf.random_normal([8])),
    'bc2': tf.Variable(tf.random_normal([16])),
    'bc3': tf.Variable(tf.random_normal([16])),
    'bc4': tf.Variable(tf.random_normal([32])),
    'bc5': tf.Variable(tf.random_normal([32])),
    'bc6': tf.Variable(tf.random_normal([32])),
    'bc7': tf.Variable(tf.random_normal([32])),
    'bc8': tf.Variable(tf.random_normal([2]))
  }

  fingerprint_input = tf.reshape(fingerprint_input, shape=[-1, 98, 40, 1], name="fingerprint_input")

  conv1 = depthwise_conv2d(fingerprint_input, weights['wc1'], biases['bc1'])

  pool1 = maxpool2d(conv1, 3)

  conv2 = conv2d(pool1, weights['wc2'], biases['bc2'])

  conv3 = conv2d(conv2, weights['wc3'], biases['bc3'])

  pool2 = maxpool2d(conv3, 3)

  conv4 = conv2d(pool2, weights['wc4'], biases['bc4'])

  conv5 = conv2d(conv4, weights['wc5'], biases['bc5'])

  conv6 = conv2d(conv5, weights['wc6'], biases['bc6'])

  conv7 = conv2d(conv6, weights['wc7'], biases['bc7'])

  fc1 = tf.contrib.layers.flatten(conv7)

  fc1 = tf.layers.dense(fc1, 2)

  sft = tf.nn.softmax(fc1, name='labels_softmax')

  if is_training:
    return sft, dropout_prob
  else:
    return sft
...