def test_hidden_layer(): x = tf.constant(np.array([[1, 2], [3, 4]], dtype='float32')) hidden_t = modeling.hidden_layer('test', x, 4) init() hidden = sess.run(hidden_t) assert hidden.shape == (2, 4)
def logits(x): hidden_sizes = [500, 350, 250, 230] with tf.name_scope('model'): x = tf.reshape(x, [data.BATCH_SIZE, data.IMG_HEIGHT, data.IMG_WIDTH]) conv1 = modeling.conv(x, 5, 32, 2, name='conv') conv_shape = conv1.get_shape().as_list() # Flatten for fully-connected layers input_t = tf.reshape( conv1, [conv_shape[0], conv_shape[1] * conv_shape[2] * conv_shape[3]]) for i, hsize in enumerate(hidden_sizes): layer_no = i + 1 input_t = modeling.hidden_layer('hidden%d' % layer_no, input_t, hsize) last_hidden = input_t logits = modeling.linear_softmax(last_hidden, NUM_CLASSES) logits = tf.identity(logits, name='logits') return logits