如何获得图层的形状/尺寸?

How to get the shape / dimension of the layers?

当我定义了这样一个模型时:

def create_basic_model_terse(input, out_dims):

    with default_options(activation=relu):
        model = Sequential([
            LayerStack(3, lambda i: [
                Convolution((5,5), [32,32,64][i], init=glorot_uniform(), pad=True),
                MaxPooling((3,3), strides=(2,2))
            ]),
            Dense(64, init=glorot_uniform()),
            Dense(out_dims, init=glorot_uniform(), activation=None)
        ])

    return model(input)

如何获得关于网络中每一层的某种信息,例如输出形状/维度?

你可以看看CNTK 202教程。还有其他教程如CNTK 105也展示了如何获取模型的不同属性。

For a model
def create_model():
with default_options(initial_state=0.1):
    return Sequential([
        Embedding(emb_dim),
        Recurrence(LSTM(hidden_dim), go_backwards=False),
        Dense(num_labels)
    ])



model = create_model()
print(len(model.layers))
print(model.layers[0].E.shape)
print(model.layers[2].b.value)