class_docstr: | `alias`: ``parl.Algorithm``
  | `alias`: ``parl.core.fluid.algorithm.Algorithm``
  
  | ``Algorithm`` defines the way how to update the parameters of the ``Model``. This is where we define loss functions and the optimizer of the neural network. An ``Algorithm`` has at least a model.
  
  | PARL has implemented various algorithms(DQN/DDPG/PPO/A3C/IMPALA) that can be reused quickly, which can be accessed with ``parl.algorithms``.
  
  Example:
  
  .. code-block:: python
  
      import parl
  
      model = Model()
      dqn = parl.algorithms.DQN(model, lr=1e-3)
  
  Attributes:
      model(``parl.Model``): a neural network that represents a policy or a Q-value function.
  
  Pulic Functions:
      - ``get_weights``: return a Python dictionary containing parameters of the current model.
      - ``set_weights``: copy parameters from ``get_weights()`` to the model.
      - ``sample``: return a noisy action to perform exploration according to the policy.
      - ``predict``: return an action given current observation.
      - ``learn``: define the loss function and create an optimizer to minized the loss.
  
  Note:
  
      ``Algorithm`` defines all its computation inside a ``fluid.Program``, such that the returns of functions(`sample`, `predict`, `learn`) are tensors.
      ``Agent`` also has functions like `sample`, `predict`, and `learn`, but they return numpy array for the agent.
      
class_docstr_tok: ["|","`","alias","`",":","``","parl.Algorithm","``","|","`","alias","`",":","``","parl.core.fluid.algorithm.Algorithm","``","|","``","Algorithm","``","defines","the","way","how","to","update","the","parameters","of","the","``","Model","``",".","This","is","where","we","define","loss","functions","and","the","optimizer","of","the","neural","network",".","An","``","Algorithm","``","has","at","least","a","model",".","|","PARL","has","implemented","various","algorithms","(","DQN\/DDPG\/PPO\/A3C\/IMPALA",")","that","can","be","reused","quickly",",","which","can","be","accessed","with","``","parl.algorithms","``",".","Example",":","..","code-block",":",":","python","import","parl","model","=","Model","(",")","dqn","=","parl.algorithms.DQN","(","model",",","lr=1e-3",")","Attributes",":","model","(","``","parl.Model","``",")",":","a","neural","network","that","represents","a","policy","or","a","Q-value","function",".","Pulic","Functions",":","-","``","get_weights","``",":","return","a","Python","dictionary","containing","parameters","of","the","current","model",".","-","``","set_weights","``",":","copy","parameters","from","``","get_weights","(",")","``","to","the","model",".","-","``","sample","``",":","return","a","noisy","action","to","perform","exploration","according","to","the","policy",".","-","``","predict","``",":","return","an","action","given","current","observation",".","-","``","learn","``",":","define","the","loss","function","and","create","an","optimizer","to","minized","the","loss",".","Note",":","``","Algorithm","``","defines","all","its","computation","inside","a","``","fluid.Program","``",",","such","that","the","returns","of","functions","(","`","sample","`",",","`","predict","`",",","`","learn","`",")","are","tensors",".","``","Agent","``","also","has","functions","like","`","sample","`",",","`","predict","`",",","and","`","learn","`",",","but","they","return","numpy","array","for","the","agent","."]
docstr: Args:
      model(``parl.Model``): a neural network that represents a policy or a Q-value function.
docstr_tok: ["Args",":","model","(","``","parl.Model","``",")",":","a","neural","network","that","represents","a","policy","or","a","Q-value","function","."]
code: def __init__(self, model=None):
      """
      Args:
          model(``parl.Model``): a neural network that represents a policy or a Q-value function.
      """
      assert isinstance(model, parl.Model)
      self.model = model
  
file_path: PARL/parl/core/fluid/algorithm.py
imports: import parl
  from parl.core.algorithm_base import AlgorithmBase
label_desc: Use image node_id 1 to create a new Algorithm object from inherited base classes: AlgorithmBase with example: obj = Algorithm(model)