2017-11-28 8 views
1

이 의견이 맞습니까? 아래에 설명 된대로 그것들은 제 모델의 5 층입니까?컨볼 루션 신경망의 계층 식별

이 층에서 모델

# input - conv - conv - linear - linear(fc) 
    def model(data): # input Layer 

     # 1 conv Layer 
     conv = tf.nn.conv2d(data, layer1_weights, [1, 2, 2, 1], padding='SAME') 
     hidden = tf.nn.relu(conv + layer1_biases) # Activation function 

     # 1 conv Layer 
     conv = tf.nn.conv2d(hidden, layer2_weights, [1, 2, 2, 1], padding='SAME') 
     hidden = tf.nn.relu(conv + layer2_biases) # Activation function 

     # not a layer (just reshape) 
     shape = hidden.get_shape().as_list() 
     reshape = tf.reshape(hidden, [shape[0], shape[1] * shape[2] * shape[3]]) 

     # 1 linear layer - not fc due to relu 
     hidden = tf.nn.relu(tf.matmul(reshape, layer3_weights) + layer3_biases) 

     # 1 linear fully connected layer 
     return tf.matmul(hidden, layer4_weights) + layer4_biases 

답변

1
# 1 linear layer - not fc due to relu 
    hidden = tf.nn.relu(tf.matmul(reshape, layer3_weights) + layer3_biases) 

는 완전히 접속 층이고, 이것은 "RELU"활성화 기능을 통과한다. 이 코드의 계층이 부분

tf.matmul(reshape, layer3_weights) + layer3_biases 

그리고 당신은

tf.nn.relu(tf.matmul(reshape, layer3_weights) + layer3_biases) 

는 다른, 다음이 모든 것이 잘 보인다 relu 활성화 기능을 통해이 층을 보내고있다.

+0

알겠습니다. 감사! –

0

댓글 라벨이 맞지만 코드에 문제가 있다고 생각합니다.

당신은 tf.nn.conv2d의 정의를 보면 : [filter_height, filter_width, in_channels, out_channels]

대신 tf.layers.conv2d을 사용할 수

conv2d(
    input, 
    filter, 
    strides, 
    padding, 
    use_cudnn_on_gpu=True, 
    data_format='NHWC', 
    name=None 
) 

당신은 두 번째 인수로 정의 무게하지만 필터 (커널) 형태가 아닌 것을 알 . 코드를 단순화하고 가중치, 바이어스 및 활성화를 한 줄로 수행합니다. 예 :

conv1 = conv2d(data, filters, kernel_size=[2, 2], padding='same', activation=tf.nn.relu) 
+0

확인해 보겠습니다. 좋은 정보, 감사합니다. –