当我定义了这样的模型时:
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)
如何获得有关网络中每个图层的某些信息,如输出形状/尺寸?
答案 0 :(得分:2)
您可以查看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)