text: #   Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
  #
  # Licensed under the Apache License, Version 2.0 (the "License");
  # you may not use this file except in compliance with the License.
  # You may obtain a copy of the License at
  #
  #     http://www.apache.org/licenses/LICENSE-2.0
  #
  # Unless required by applicable law or agreed to in writing, software
  # distributed under the License is distributed on an "AS IS" BASIS,
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  # See the License for the specific language governing permissions and
  # limitations under the License.
  
  # 导入需要的包
  import paddle
  import paddle.fluid as fluid
  import numpy as np
  from paddle.fluid.dygraph.nn import Conv2D, Pool2D, Linear
  
  
  # 定义 LeNet 网络结构
  class LeNet(fluid.dygraph.Layer):
      def __init__(self, name_scope, num_classes=1):
          super(LeNet, self).__init__(name_scope)
  
          # 创建卷积和池化层块，每个卷积层使用Sigmoid激活函数，后面跟着一个2x2的池化
          self.conv1 = Conv2D(num_channels=1,
                              num_filters=6,
                              filter_size=5,
                              act='sigmoid')
          self.pool1 = Pool2D(pool_size=2, pool_stride=2, pool_type='max')
          self.conv2 = Conv2D(num_channels=6,
                              num_filters=16,
                              filter_size=5,
                              act='sigmoid')
          self.pool2 = Pool2D(pool_size=2, pool_stride=2, pool_type='max')
          # 创建第3个卷积层
          self.conv3 = Conv2D(num_channels=16,
                              num_filters=120,
                              filter_size=4,
                              act='sigmoid')
          # 创建全连接层，第一个全连接层的输出神经元个数为64， 第二个全连接层输出神经元个数为分裂标签的类别数
          self.fc1 = Linear(input_dim=120, output_dim=64, act='sigmoid')
          self.fc2 = Linear(input_dim=64, output_dim=num_classes)
  
      # 网络的前向计算过程
      def forward(self, x):
          x = self.conv1(x)
          x = self.pool1(x)
          x = self.conv2(x)
          x = self.pool2(x)
          x = self.conv3(x)
          x = fluid.layers.reshape(x, [x.shape[0], -1])
          x = self.fc1(x)
          x = self.fc2(x)
          return x
  