【问题标题】:CNTK has no attribute LeakyReLUCNTK 没有属性 LeakyReLU
【发布时间】:2017-10-13 08:26:47
【问题描述】:

在制作这样的 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(最近调用 最后)在() 1 # 创建模型 ----> 2 z = create_model(x) 3 4 # 打印不同组件的输出形状/参数 5 print("第一个卷积层的输出Shape:", z.first_conv.shape)

在 create_model(features) 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'

我是深度学习的新手,所以我可能会遗漏一些简单的东西。任何帮助表示赞赏。谢谢!

【问题讨论】:

    标签: python machine-learning deep-learning cntk


    【解决方案1】:

    试试C.leaky_relu:

    >>> C.leaky_relu([[-1, -0.5, 0, 1, 2]]).eval()
    array([[-0.01 , -0.005,  0.   ,  1.   ,  2.   ]], dtype=float32)
    

    【讨论】:

      【解决方案2】:

      将以下行改为:

      使用 C.layers.default_options(init=C.glorot_uniform(), activation=C.leaky_relu):

      【讨论】:

        猜你喜欢
        • 2019-08-07
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-12-01
        • 1970-01-01
        • 2011-04-14
        • 2020-01-06
        • 1970-01-01
        相关资源
        最近更新 更多