1
內兩層我目前使用重新實現的CNTK我Jonathan Longs FCN8-s實施TensorFlow。雖然TensorFlow是非常同時所熟悉我,我在使用微軟的CNTK但非常缺乏經驗。我讀了幾CNTK Github上教程,但現在我在這裏我想與upscore層添加pool4_score點。在TensorFlow我會簡單地使用tf.add(pool4_score, upscore1)
但CNTK我必須使用Sequentials(正確嗎?)所以我的代碼如下所示:如何添加CNTK順序
with default_options(activation=None, pad=True, bias=True):
z = Sequential([
For(range(2), lambda i: [
Convolution2D((3,3), 64, pad=True, name='conv1_{}'.format(i)),
Activation(activation=relu, name='relu1_{}'.format(i)),
]),
MaxPooling((2,2), (2,2), name='pool1'),
For(range(2), lambda i: [
Convolution2D((3,3), 128, pad=True, name='conv2_{}'.format(i)),
Activation(activation=relu, name='relu2_{}'.format(i)),
]),
MaxPooling((2,2), (2,2), name='pool2'),
For(range(3), lambda i: [
Convolution2D((3,3), 256, pad=True, name='conv3_{}'.format(i)),
Activation(activation=relu, name='relu3_{}'.format(i)),
]),
MaxPooling((2,2), (2,2), name='pool3'),
For(range(3), lambda i: [
Convolution2D((3,3), 512, pad=True, name='conv4_{}'.format(i)),
Activation(activation=relu, name='relu4_{}'.format(i)),
]),
MaxPooling((2,2), (2,2), name='pool4'),
For(range(3), lambda i: [
Convolution2D((3,3), 512, pad=True, name='conv5_{}'.format(i)),
Activation(activation=relu, name='relu5_{}'.format(i)),
]),
MaxPooling((2,2), (2,2), name='pool5'),
Convolution2D((7,7), 4096, pad=True, name='fc6'),
Activation(activation=relu, name='relu6'),
Dropout(0.5, name='drop6'),
Convolution2D((1,1), 4096, pad=True, name='fc7'),
Activation(activation=relu, name='relu7'),
Dropout(0.5, name='drop7'),
Convolution2D((1,1), num_classes, pad=True, name='fc8')
ConvolutionTranspose2D((4,4), num_classes, strides=(1,2), name='upscore1')
# TODO:
# conv for pool4_score with (1x512) and 21 classes
# combine upscore 1 and pool4_score
])(input)
我看是有combine
方法。但是我發現沒有例子怎麼用它在順序內。因此,如何將使用CNTK我實現tf.add
方法?
非常感謝!