SRL/Autoencoder: 如何根据既有网络层构建解码器

对输入的重构通过编码器和解码器完成。例如:
obs —encoder—> state presentation —decoder—> obs_reconstruction

根据既有网络层(编码器)构建解码器时,根据编码器的变量shape确定对应的解码器output_shape. For example:

    # encoder
    conv1 = layers.conv2d(
        num_filters=32, filter_size=8, stride=4, padding=1, act='relu')
    conv2 = layers.conv2d(
        num_filters=64, filter_size=4, stride=2, padding=2, act='relu')
    conv3 = layers.conv2d(
        num_filters=64, filter_size=3, stride=1, padding=0, act='relu')
    fc = layers.fc(size=512, act='relu')
    
    # normally, we flatten input before **fc**, and reshape before **defc**

    # decoder
    defc = layers.fc(size=5184, act='relu')
    deconv3 = layers.conv2d_transpose(
        num_filters=64, filter_size=3, stride=1, padding=0, act='relu')
    deconv2 = layers.conv2d_transpose(
        num_filters=32, filter_size=4, stride=2, padding=2, act='relu')
    deconv1 = layers.conv2d_transpose(
        num_filters=4, filter_size=8, stride=4, padding=0, act='relu')

参数详情可参考https://www.paddlepaddle.org.cn/documentation/docs/zh/api_cn/dygraph_cn.html#conv2dtranspose

你可能感兴趣的:(SRL/Autoencoder: 如何根据既有网络层构建解码器)