parameters: (net, input_size=None, dtypes=None, input=None)
return_statement: return params_info
docstring: Prints a string summary of the network.
  
      Args:
          net (Layer): the network which must be a subinstance of Layer.
          input_size (tuple|InputSpec|list[tuple|InputSpec]): size of input tensor. if model only 
                      have one input, input_size can be tuple or InputSpec. if model
                      have multiple input, input_size must be a list which contain 
                      every input's shape. Note that input_size only dim of
                      batch_size can be None or -1. Default: None. Note that 
                      input_size and input cannot be None at the same time.
          dtypes (str, optional): if dtypes is None, 'float32' will be used, Default: None.
          input: the input tensor. if input is given, input_size and dtype will be ignored, Default: None.
  
      Returns:
          Dict: a summary of the network including total params and total trainable params.
  
      Examples:
          .. code-block:: python
  
              import paddle
              import paddle.nn as nn
  
              class LeNet(nn.Layer):
                  def __init__(self, num_classes=10):
                      super(LeNet, self).__init__()
                      self.num_classes = num_classes
                      self.features = nn.Sequential(
                          nn.Conv2D(
                              1, 6, 3, stride=1, padding=1),
                          nn.ReLU(),
                          nn.MaxPool2D(2, 2),
                          nn.Conv2D(
                              6, 16, 5, stride=1, padding=0),
                          nn.ReLU(),
                          nn.MaxPool2D(2, 2))
  
                      if num_classes > 0:
                          self.fc = nn.Sequential(
                              nn.Linear(400, 120),
                              nn.Linear(120, 84),
                              nn.Linear(
                                  84, 10))
  
                  def forward(self, inputs):
                      x = self.features(inputs)
  
                      if self.num_classes > 0:
                          x = paddle.flatten(x, 1)
                          x = self.fc(x)
                      return x
  
              lenet = LeNet()
  
              params_info = paddle.summary(lenet, (1, 1, 28, 28))
              print(params_info)
  
              # multi input demo
              class LeNetMultiInput(LeNet):
  
                  def forward(self, inputs, y):
                      x = self.features(inputs)
  
                      if self.num_classes > 0:
                          x = paddle.flatten(x, 1)
                          x = self.fc(x + y)
                      return x
              
              lenet_multi_input = LeNetMultiInput()
  
              params_info = paddle.summary(lenet_multi_input, [(1, 1, 28, 28), (1, 400)], 
                                          dtypes=['float32', 'float32'])
              print(params_info)
  
              # list input demo
              class LeNetListInput(LeNet):
  
                  def forward(self, inputs):
                      x = self.features(inputs[0])
  
                      if self.num_classes > 0:
                          x = paddle.flatten(x, 1)
                          x = self.fc(x + inputs[1])
                      return x
              
              lenet_list_input = LeNetListInput()
              input_data = [paddle.rand([1, 1, 28, 28]), paddle.rand([1, 400])]
              params_info = paddle.summary(lenet_list_input, input=input_data)
              print(params_info)
  
              # dict input demo
              class LeNetDictInput(LeNet):
  
                  def forward(self, inputs):
                      x = self.features(inputs['x1'])
  
                      if self.num_classes > 0:
                          x = paddle.flatten(x, 1)
                          x = self.fc(x + inputs['x2'])
                      return x
  
              lenet_dict_input = LeNetDictInput()
              input_data = {'x1': paddle.rand([1, 1, 28, 28]),
                            'x2': paddle.rand([1, 400])}
              params_info = paddle.summary(lenet_dict_input, input=input_data)
              print(params_info)
docstring_summary: Prints a string summary of the network.
docstring_tokens: Prints a string summary of the network .
function: def summary(net, input_size=None, dtypes=None, input=None):
      """Prints a string summary of the network.
  
      Args:
          net (Layer): the network which must be a subinstance of Layer.
          input_size (tuple|InputSpec|list[tuple|InputSpec]): size of input tensor. if model only 
                      have one input, input_size can be tuple or InputSpec. if model
                      have multiple input, input_size must be a list which contain 
                      every input's shape. Note that input_size only dim of
                      batch_size can be None or -1. Default: None. Note that 
                      input_size and input cannot be None at the same time.
          dtypes (str, optional): if dtypes is None, 'float32' will be used, Default: None.
          input: the input tensor. if input is given, input_size and dtype will be ignored, Default: None.
  
      Returns:
          Dict: a summary of the network including total params and total trainable params.
  
      Examples:
          .. code-block:: python
  
              import paddle
              import paddle.nn as nn
  
              class LeNet(nn.Layer):
                  def __init__(self, num_classes=10):
                      super(LeNet, self).__init__()
                      self.num_classes = num_classes
                      self.features = nn.Sequential(
                          nn.Conv2D(
                              1, 6, 3, stride=1, padding=1),
                          nn.ReLU(),
                          nn.MaxPool2D(2, 2),
                          nn.Conv2D(
                              6, 16, 5, stride=1, padding=0),
                          nn.ReLU(),
                          nn.MaxPool2D(2, 2))
  
                      if num_classes > 0:
                          self.fc = nn.Sequential(
                              nn.Linear(400, 120),
                              nn.Linear(120, 84),
                              nn.Linear(
                                  84, 10))
  
                  def forward(self, inputs):
                      x = self.features(inputs)
  
                      if self.num_classes > 0:
                          x = paddle.flatten(x, 1)
                          x = self.fc(x)
                      return x
  
              lenet = LeNet()
  
              params_info = paddle.summary(lenet, (1, 1, 28, 28))
              print(params_info)
  
              # multi input demo
              class LeNetMultiInput(LeNet):
  
                  def forward(self, inputs, y):
                      x = self.features(inputs)
  
                      if self.num_classes > 0:
                          x = paddle.flatten(x, 1)
                          x = self.fc(x + y)
                      return x
              
              lenet_multi_input = LeNetMultiInput()
  
              params_info = paddle.summary(lenet_multi_input, [(1, 1, 28, 28), (1, 400)], 
                                          dtypes=['float32', 'float32'])
              print(params_info)
  
              # list input demo
              class LeNetListInput(LeNet):
  
                  def forward(self, inputs):
                      x = self.features(inputs[0])
  
                      if self.num_classes > 0:
                          x = paddle.flatten(x, 1)
                          x = self.fc(x + inputs[1])
                      return x
              
              lenet_list_input = LeNetListInput()
              input_data = [paddle.rand([1, 1, 28, 28]), paddle.rand([1, 400])]
              params_info = paddle.summary(lenet_list_input, input=input_data)
              print(params_info)
  
              # dict input demo
              class LeNetDictInput(LeNet):
  
                  def forward(self, inputs):
                      x = self.features(inputs['x1'])
  
                      if self.num_classes > 0:
                          x = paddle.flatten(x, 1)
                          x = self.fc(x + inputs['x2'])
                      return x
  
              lenet_dict_input = LeNetDictInput()
              input_data = {'x1': paddle.rand([1, 1, 28, 28]),
                            'x2': paddle.rand([1, 400])}
              params_info = paddle.summary(lenet_dict_input, input=input_data)
              print(params_info)
  
      """
      if input_size is None and input is None:
          raise ValueError("input_size and input cannot be None at the same time")
  
      if input_size is None and input is not None:
          if paddle.is_tensor(input):
              input_size = tuple(input.shape)
          elif isinstance(input, (list, tuple)):
              input_size = []
              for x in input:
                  input_size.append(tuple(x.shape))
          elif isinstance(input, dict):
              input_size = []
              for key in input.keys():
                  input_size.append(tuple(input[key].shape))
          elif isinstance(input, paddle.fluid.framework.Variable):
              input_size = tuple(input.shape)
          else:
              raise ValueError(
                  "Input is not tensor, list, tuple and dict, unable to determine input_size, please input input_size."
              )
  
      if isinstance(input_size, InputSpec):
          _input_size = tuple(input_size.shape)
      elif isinstance(input_size, list):
          _input_size = []
          for item in input_size:
              if isinstance(item, int):
                  item = (item, )
              assert isinstance(item,
                                (tuple, InputSpec)), 'When input_size is list, \
              expect item in input_size is a tuple or InputSpec, but got {}'.format(
                                    type(item))
  
              if isinstance(item, InputSpec):
                  _input_size.append(tuple(item.shape))
              else:
                  _input_size.append(item)
      elif isinstance(input_size, int):
          _input_size = (input_size, )
      else:
          _input_size = input_size
  
      if not paddle.in_dynamic_mode():
          warnings.warn(
              "Your model was created in static mode, this may not get correct summary information!"
          )
          in_train_mode = False
      else:
          in_train_mode = net.training
  
      if in_train_mode:
          net.eval()
  
      def _is_shape(shape):
          for item in shape:
              if isinstance(item, (list, tuple)):
                  return False
          return True
  
      def _check_shape(shape):
          num_unknown = 0
          new_shape = []
          for i in range(len(shape)):
              item = shape[i]
              if item is None or item == -1:
                  num_unknown += 1
                  if num_unknown > 1:
                      raise ValueError(
                          'Option input_size only the dim of batch_size can be None or -1.'
                      )
                  item = 1
              elif isinstance(item, numbers.Number):
                  if item <= 0:
                      raise ValueError(
                          "Expected element in input size greater than zero, but got {}".
                          format(item))
              new_shape.append(item)
          return tuple(new_shape)
  
      def _check_input(input_size):
          if isinstance(input_size, (list, tuple)) and _is_shape(input_size):
              return _check_shape(input_size)
          else:
              return [_check_input(i) for i in input_size]
  
      _input_size = _check_input(_input_size)
  
      result, params_info = summary_string(net, _input_size, dtypes, input)
      print(result)
  
      if in_train_mode:
          net.train()
  
      return params_info
function_tokens: def summary ( net , input_size = None , dtypes = None , input = None ) : if input_size is None and input is None : raise ValueError ( "input_size and input cannot be None at the same time" ) if input_size is None and input is not None : if paddle . is_tensor ( input ) : input_size = tuple ( input . shape ) elif isinstance ( input , ( list , tuple ) ) : input_size = [ ] for x in input : input_size . append ( tuple ( x . shape ) ) elif isinstance ( input , dict ) : input_size = [ ] for key in input . keys ( ) : input_size . append ( tuple ( input [ key ] . shape ) ) elif isinstance ( input , paddle . fluid . framework . Variable ) : input_size = tuple ( input . shape ) else : raise ValueError ( "Input is not tensor, list, tuple and dict, unable to determine input_size, please input input_size." ) if isinstance ( input_size , InputSpec ) : _input_size = tuple ( input_size . shape ) elif isinstance ( input_size , list ) : _input_size = [ ] for item in input_size : if isinstance ( item , int ) : item = ( item , ) assert isinstance ( item , ( tuple , InputSpec ) ) , 'When input_size is list, \
              expect item in input_size is a tuple or InputSpec, but got {}' . format ( type ( item ) ) if isinstance ( item , InputSpec ) : _input_size . append ( tuple ( item . shape ) ) else : _input_size . append ( item ) elif isinstance ( input_size , int ) : _input_size = ( input_size , ) else : _input_size = input_size if not paddle . in_dynamic_mode ( ) : warnings . warn ( "Your model was created in static mode, this may not get correct summary information!" ) in_train_mode = False else : in_train_mode = net . training if in_train_mode : net . eval ( ) def _is_shape ( shape ) : for item in shape : if isinstance ( item , ( list , tuple ) ) : return False return True def _check_shape ( shape ) : num_unknown = 0 new_shape = [ ] for i in range ( len ( shape ) ) : item = shape [ i ] if item is None or item == - 1 : num_unknown += 1 if num_unknown > 1 : raise ValueError ( 'Option input_size only the dim of batch_size can be None or -1.' ) item = 1 elif isinstance ( item , numbers . Number ) : if item <= 0 : raise ValueError ( "Expected element in input size greater than zero, but got {}" . format ( item ) ) new_shape . append ( item ) return tuple ( new_shape ) def _check_input ( input_size ) : if isinstance ( input_size , ( list , tuple ) ) and _is_shape ( input_size ) : return _check_shape ( input_size ) else : return [ _check_input ( i ) for i in input_size ] _input_size = _check_input ( _input_size ) result , params_info = summary_string ( net , _input_size , dtypes , input ) print ( result ) if in_train_mode : net . train ( ) return params_info