parameters: (nb_classes, resnet_layers, input_shape, activation='softmax')
return_statement: return model
docstring: Build PSPNet.
docstring_summary: Build PSPNet.
docstring_tokens: Build PSPNet .
function: def build_pspnet(nb_classes, resnet_layers, input_shape, activation='softmax'):
      """Build PSPNet."""
      print("Building a PSPNet based on ResNet %i expecting inputs of shape %s predicting %i classes" % (
          resnet_layers, input_shape, nb_classes))
  
      inp = Input((input_shape[0], input_shape[1], 3))
      res = ResNet(inp, layers=resnet_layers)
      psp = build_pyramid_pooling_module(res, input_shape)
  
      x = Conv2D(512, (3, 3), strides=(1, 1), padding="same", name="conv5_4",
                 use_bias=False)(psp)
      x = BN(name="conv5_4_bn")(x)
      x = Activation('relu')(x)
      x = Dropout(0.1)(x)
  
      x = Conv2D(nb_classes, (1, 1), strides=(1, 1), name="conv6")(x)
      # x = Lambda(Interp, arguments={'shape': (
      #    input_shape[0], input_shape[1])})(x)
      x = Interp([input_shape[0], input_shape[1]])(x)
      x = Activation('softmax')(x)
  
      model = Model(inputs=inp, outputs=x)
  
      # Solver
      sgd = SGD(lr=learning_rate, momentum=0.9, nesterov=True)
      model.compile(optimizer=sgd,
                    loss='categorical_crossentropy',
                    metrics=['accuracy'])
      return model
function_tokens: def build_pspnet ( nb_classes , resnet_layers , input_shape , activation = 'softmax' ) : print ( "Building a PSPNet based on ResNet %i expecting inputs of shape %s predicting %i classes" % ( resnet_layers , input_shape , nb_classes ) ) inp = Input ( ( input_shape [ 0 ] , input_shape [ 1 ] , 3 ) ) res = ResNet ( inp , layers = resnet_layers ) psp = build_pyramid_pooling_module ( res , input_shape ) x = Conv2D ( 512 , ( 3 , 3 ) , strides = ( 1 , 1 ) , padding = "same" , name = "conv5_4" , use_bias = False ) ( psp ) x = BN ( name = "conv5_4_bn" ) ( x ) x = Activation ( 'relu' ) ( x ) x = Dropout ( 0.1 ) ( x ) x = Conv2D ( nb_classes , ( 1 , 1 ) , strides = ( 1 , 1 ) , name = "conv6" ) ( x ) # x = Lambda(Interp, arguments={'shape': ( #    input_shape[0], input_shape[1])})(x) x = Interp ( [ input_shape [ 0 ] , input_shape [ 1 ] ] ) ( x ) x = Activation ( 'softmax' ) ( x ) model = Model ( inputs = inp , outputs = x ) # Solver sgd = SGD ( lr = learning_rate , momentum = 0.9 , nesterov = True ) model . compile ( optimizer = sgd , loss = 'categorical_crossentropy' , metrics = [ 'accuracy' ] ) return model