pixelkeras.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:Generative-models 作者: aalitaiga 项目源码 文件源码
def create_network():
    # PixelCNN architecture, no pooling layer
    x = Input(batch_shape=(batch_size,n_channel,mnist_dim,mnist_dim))

    # First layer using  mask A
    x_ = Convolution2DNoFlip(*first_layer, input_shape=(1, 28, 28), border_mode='same', mask='A')(x)

    # Second type of layers using mask B
    for i in range(n_layer // 2):
        x_1 = Convolution2DNoFlip(*second_layer, activation='relu', border_mode='same', mask='B')(x_)
        x_2 = Convolution2DNoFlip(*second_layer, activation='relu', border_mode='same', mask='B')(x_1)

        if res_connections:
            x_ = merge([x_, x_2], mode='sum')
        else:
            x_ = x_2

    # 2 layers of Relu followed by 1x1 conv
    x_ = Convolution2DNoFlip(64, 1, 1, activation='relu', border_mode='same', mask='B')(x_)
    x_ = Convolution2DNoFlip(128, 1, 1, activation='relu', border_mode='same', mask='B')(x_)

    # Depending on the output
    x_ = Convolution2DNoFlip(*third_layer,border_mode='same', mask='B')(x_)

    if MODE == '256ary':
        x_ = Reshape((256, mnist_dim**2))(x_)
        x_ = Permute((2,1))(x_)

    y = Activation(activation)(x_)

    model = Model(x, y)
    model.compile(optimizer='adagrad', loss=cost)
    print "Model compiled"
    return model
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号