class_docstr: A class used to set and get weights for Tensorflow networks.
  
  Attributes:
      sess (tf.Session): The tensorflow session used to run assignment.
      variables (Dict[str, tf.Variable]): Extracted variables from the loss
          or additional variables that are passed in.
      placeholders (Dict[str, tf.placeholders]): Placeholders for weights.
      assignment_nodes (Dict[str, tf.Tensor]): Nodes that assign weights.
class_docstr_tok: ["A","class","used","to","set","and","get","weights","for","Tensorflow","networks",".","Attributes",":","sess","(","tf.Session",")",":","The","tensorflow","session","used","to","run","assignment",".","variables","(","Dict","[","str",",","tf.Variable","]",")",":","Extracted","variables","from","the","loss","or","additional","variables","that","are","passed","in",".","placeholders","(","Dict","[","str",",","tf.placeholders","]",")",":","Placeholders","for","weights",".","assignment_nodes","(","Dict","[","str",",","tf.Tensor","]",")",":","Nodes","that","assign","weights","."]
docstr: Sets the weights to new_weights, converting from a flat array.
  
  Note:
      You can only set all weights in the network using this function,
      i.e., the length of the array must match get_flat_size.
  
  Args:
      new_weights (np.ndarray): Flat array containing weights.
docstr_tok: ["Sets","the","weights","to","new_weights",",","converting","from","a","flat","array",".","Note",":","You","can","only","set","all","weights","in","the","network","using","this","function",",","i.e.",",","the","length","of","the","array","must","match","get_flat_size",".","Args",":","new_weights","(","np.ndarray",")",":","Flat","array","containing","weights","."]
code: def set_flat(self, new_weights):
      """Sets the weights to new_weights, converting from a flat array.
  
      Note:
          You can only set all weights in the network using this function,
          i.e., the length of the array must match get_flat_size.
  
      Args:
          new_weights (np.ndarray): Flat array containing weights.
      """
      shapes = [
          v.get_shape().as_list() for v in self.variables.values()
      ]
      arrays = unflatten(new_weights, shapes)
      if not self.sess:
          for v, a in zip(self.variables.values(), arrays):
              v.assign(a)
      else:
          placeholders = [
              self.placeholders[k] for k, v in self.variables.items()
          ]
          self.sess.run(
              list(self.assignment_nodes.values()),
              feed_dict=dict(zip(placeholders, arrays)),
          )
  
file_path: ray/python/ray/experimental/tf_utils.py
imports: from collections import OrderedDict, deque
  import numpy
  from ray.rllib.utils import force_list
  from ray.rllib.utils.framework import try_import_tf
label_desc: Use image node_id 4 for calling the TensorFlowVariables obj's underlying member method code with example usage: obj.set_flat(new_weights) without return types