parameters: (self)
return_statement: return net_params
docstring: Retrieve weights from the TF model, convert to the format Core ML
          expects and store in a dictionary.
  
          Returns
          -------
          net_params : dict
              Dictionary of weights, where the key is the name of the
              layer (e.g. `drawing_conv0_weight`) and the value is the
              respective weight of type `numpy.ndarray`.
docstring_summary: Retrieve weights from the TF model, convert to the format Core ML
          expects and store in a dictionary.
docstring_tokens: Retrieve weights from the TF model convert to the format Core ML expects and store in a dictionary .
function: def export_weights(self):
          """
          Retrieve weights from the TF model, convert to the format Core ML
          expects and store in a dictionary.
  
          Returns
          -------
          net_params : dict
              Dictionary of weights, where the key is the name of the
              layer (e.g. `drawing_conv0_weight`) and the value is the
              respective weight of type `numpy.ndarray`.
          """
  
          net_params = {}
  
          _tf = _lazy_import_tensorflow()
          with self.dc_graph.as_default():
              layer_names = _tf.trainable_variables()
              layer_weights = self.sess.run(layer_names)
  
          for var, val in zip(layer_names, layer_weights):
              if "bias" in var.name:
                  net_params.update({var.name.replace(":0", ""): val})
              else:
                  if "dense" in var.name:
                      if "drawing_dense0_weight" in var.name:
                          """
                           To make output of TF pool3 (NHWC) compatible with CoreML (NCHW).
                           Decompose FC weights to NHWC. Transpose to NCHW. Reshape back to FC.
                           """
                          tf_576_128 = val
                          tf_576_128 = _np.reshape(tf_576_128, (3, 3, 64, 128))
                          tf_576_128 = _np.transpose(tf_576_128, (2, 0, 1, 3))
                          tf_576_128 = _np.reshape(tf_576_128, (576, 128))
                          net_params.update(
                              {
                                  var.name.replace(":0", ""): _np.transpose(
                                      tf_576_128, (1, 0)
                                  )
                              }
                          )
                      else:
                          net_params.update(
                              {var.name.replace(":0", ""): val.transpose(1, 0)}
                          )
                  else:
                      # np.transpose won't change the underlying memory layout
                      # but in turicreate we will force it.
                      net_params.update(
                          {
                              var.name.replace(
                                  ":0", ""
                              ): _utils.convert_conv2d_tf_to_coreml(val)
                          }
                      )
  
          return net_params
function_tokens: def export_weights ( self ) : net_params = { } _tf = _lazy_import_tensorflow ( ) with self . dc_graph . as_default ( ) : layer_names = _tf . trainable_variables ( ) layer_weights = self . sess . run ( layer_names ) for var , val in zip ( layer_names , layer_weights ) : if "bias" in var . name : net_params . update ( { var . name . replace ( ":0" , "" ) : val } ) else : if "dense" in var . name : if "drawing_dense0_weight" in var . name : """
                           To make output of TF pool3 (NHWC) compatible with CoreML (NCHW).
                           Decompose FC weights to NHWC. Transpose to NCHW. Reshape back to FC.
                           """ tf_576_128 = val tf_576_128 = _np . reshape ( tf_576_128 , ( 3 , 3 , 64 , 128 ) ) tf_576_128 = _np . transpose ( tf_576_128 , ( 2 , 0 , 1 , 3 ) ) tf_576_128 = _np . reshape ( tf_576_128 , ( 576 , 128 ) ) net_params . update ( { var . name . replace ( ":0" , "" ) : _np . transpose ( tf_576_128 , ( 1 , 0 ) ) } ) else : net_params . update ( { var . name . replace ( ":0" , "" ) : val . transpose ( 1 , 0 ) } ) else : # np.transpose won't change the underlying memory layout # but in turicreate we will force it. net_params . update ( { var . name . replace ( ":0" , "" ) : _utils . convert_conv2d_tf_to_coreml ( val ) } ) return net_params