【问题标题】:How to get the shape / dimension of the layers?如何获得图层的形状/尺寸?
【发布时间】:2017-02-13 17:49:40
【问题描述】:

当我定义了这样的模型时:

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


    【解决方案1】:

    您可以查看 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)

    【讨论】:

    • 谢谢,我还让 TensorBoard 与 CNTK 一起工作,所以这也是一个选项。
    猜你喜欢
    • 1970-01-01
    • 2014-03-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-28
    • 1970-01-01
    相关资源
    最近更新 更多