【发布时间】:2017-09-15 07:44:13
【问题描述】:
我目前正在使用 CNTK 重新实现 Jonathan Longs FCN8-s 的 TensorFlow 实现。虽然 TensorFlow 同时对我来说非常熟悉,但我在使用 Microsoft 的 CNTK 方面还非常缺乏经验。我阅读了一些 CNTK Github 教程,但现在我想在 upscore 层中添加 pool4_score 。在 TensorFlow 中我会简单地使用 tf.add(pool4_score, upscore1) 但在 CNTK 中我必须使用 Sequentials(对吗?)所以我的代码看起来像:
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 方法呢?
非常感谢!
【问题讨论】:
标签: python tensorflow computer-vision cntk