制作这样的CNN模型时:
# function to build model
def create_model(features):
with C.layers.default_options(init=C.glorot_uniform(), activation=C.LeakyReLU):
h = features
h = C.layers.Convolution2D(filter_shape=(5,5),
num_filters=8,
strides=(2,2),
pad=True, name='first_conv')(h)
h = C.layers.Convolution2D(filter_shape=(5,5),
num_filters=16,
strides=(2,2),
pad=True, name='second_conv')(h)
r = C.layers.Dense(num_output_classes, activation=None, name='classify')(h)
return r
# Create the model
z = create_model(x)
# Print the output shapes / parameters of different components
print("Output Shape of the first convolution layer:", z.first_conv.shape)
print("Bias value of the last dense layer:", z.classify.b.value)
AttributeError Traceback(最近一次调用 最后)in() 1#创建模型 ----> 2 z = create_model(x) 3 4#打印不同组件的输出形状/参数 5打印(“第一卷积层的输出形状:”,z.first_conv.shape)
create_model中的(功能) 2 3 def create_model(功能): ----> 4与C.layers.default_options(init = C.glorot_uniform(),activation = C.LeakyReLU): 5小时=特征 6 h = C.layers.Convolution2D(filter_shape =(5,5),
AttributeError:模块'cntk'没有属性'LeakyReLU'
我是深度学习的新手,所以我可能会遗漏一些简单的东西。任何帮助表示赞赏。谢谢!
答案 0 :(得分:3)
尝试C.leaky_relu
:
>>> C.leaky_relu([[-1, -0.5, 0, 1, 2]]).eval()
array([[-0.01 , -0.005, 0. , 1. , 2. ]], dtype=float32)
答案 1 :(得分:1)
将以下行更改为:
使用C.layers.default_options(init = C.glorot_uniform(),激活= C. leaky_relu ):