deepmd.tf.loss.ener
===================

.. py:module:: deepmd.tf.loss.ener


Classes
-------

.. autoapisummary::

   deepmd.tf.loss.ener.EnerStdLoss
   deepmd.tf.loss.ener.EnerSpinLoss
   deepmd.tf.loss.ener.EnerDipoleLoss


Module Contents
---------------

.. py:class:: EnerStdLoss(starter_learning_rate: float, start_pref_e: float = 0.02, limit_pref_e: float = 1.0, start_pref_f: float = 1000, limit_pref_f: float = 1.0, start_pref_v: float = 0.0, limit_pref_v: float = 0.0, start_pref_ae: float = 0.0, limit_pref_ae: float = 0.0, start_pref_pf: float = 0.0, limit_pref_pf: float = 0.0, relative_f: Optional[float] = None, enable_atom_ener_coeff: bool = False, start_pref_gf: float = 0.0, limit_pref_gf: float = 0.0, numb_generalized_coord: int = 0, **kwargs)

   Bases: :py:obj:`deepmd.tf.loss.loss.Loss`


   
   Standard loss function for DP models.


   :Parameters:

       **starter_learning_rate** : :class:`python:float`
           The learning rate at the start of the training.

       **start_pref_e** : :class:`python:float`
           The prefactor of energy loss at the start of the training.

       **limit_pref_e** : :class:`python:float`
           The prefactor of energy loss at the end of the training.

       **start_pref_f** : :class:`python:float`
           The prefactor of force loss at the start of the training.

       **limit_pref_f** : :class:`python:float`
           The prefactor of force loss at the end of the training.

       **start_pref_v** : :class:`python:float`
           The prefactor of virial loss at the start of the training.

       **limit_pref_v** : :class:`python:float`
           The prefactor of virial loss at the end of the training.

       **start_pref_ae** : :class:`python:float`
           The prefactor of atomic energy loss at the start of the training.

       **limit_pref_ae** : :class:`python:float`
           The prefactor of atomic energy loss at the end of the training.

       **start_pref_pf** : :class:`python:float`
           The prefactor of atomic prefactor force loss at the start of the training.

       **limit_pref_pf** : :class:`python:float`
           The prefactor of atomic prefactor force loss at the end of the training.

       **relative_f** : :class:`python:float`
           If provided, relative force error will be used in the loss. The difference
           of force will be normalized by the magnitude of the force in the label with
           a shift given by relative_f

       **enable_atom_ener_coeff** : :ref:`bool <python:bltin-boolean-values>`
           if true, the energy will be computed as \sum_i c_i E_i

       **start_pref_gf** : :class:`python:float`
           The prefactor of generalized force loss at the start of the training.

       **limit_pref_gf** : :class:`python:float`
           The prefactor of generalized force loss at the end of the training.

       **numb_generalized_coord** : :class:`python:int`
           The dimension of generalized coordinates.

       **\*\*kwargs**
           Other keyword arguments.














   ..
       !! processed by numpydoc !!

   .. py:attribute:: starter_learning_rate


   .. py:attribute:: start_pref_e
      :value: 0.02



   .. py:attribute:: limit_pref_e
      :value: 1.0



   .. py:attribute:: start_pref_f
      :value: 1000



   .. py:attribute:: limit_pref_f
      :value: 1.0



   .. py:attribute:: start_pref_v
      :value: 0.0



   .. py:attribute:: limit_pref_v
      :value: 0.0



   .. py:attribute:: start_pref_ae
      :value: 0.0



   .. py:attribute:: limit_pref_ae
      :value: 0.0



   .. py:attribute:: start_pref_pf
      :value: 0.0



   .. py:attribute:: limit_pref_pf
      :value: 0.0



   .. py:attribute:: relative_f
      :value: None



   .. py:attribute:: enable_atom_ener_coeff
      :value: False



   .. py:attribute:: start_pref_gf
      :value: 0.0



   .. py:attribute:: limit_pref_gf
      :value: 0.0



   .. py:attribute:: numb_generalized_coord
      :value: 0



   .. py:attribute:: has_e


   .. py:attribute:: has_f


   .. py:attribute:: has_v


   .. py:attribute:: has_ae


   .. py:attribute:: has_pf


   .. py:attribute:: has_gf


   .. py:method:: build(learning_rate, natoms, model_dict, label_dict, suffix)

      
      Build the loss function graph.


      :Parameters:

          **learning_rate** : :obj:`tf.Tensor`
              learning rate

          **natoms** : :obj:`tf.Tensor`
              number of atoms

          **model_dict** : :class:`python:dict`\[:class:`python:str`, :obj:`tf.Tensor`]
              A dictionary that maps model keys to tensors

          **label_dict** : :class:`python:dict`\[:class:`python:str`, :obj:`tf.Tensor`]
              A dictionary that maps label keys to tensors

          **suffix** : :class:`python:str`
              suffix



      :Returns:

          :obj:`tf.Tensor`
              the total squared loss

          :class:`python:dict`\[:class:`python:str`, :obj:`tf.Tensor`]
              A dictionary that maps loss keys to more loss tensors











      ..
          !! processed by numpydoc !!


   .. py:method:: eval(sess, feed_dict, natoms)

      
      Eval the loss function.


      :Parameters:

          **sess** : :obj:`tf.Session`
              TensorFlow session

          **feed_dict** : :class:`python:dict`\[:obj:`tf.placeholder`, :obj:`tf.Tensor`]
              A dictionary that maps graph elements to values

          **natoms** : :obj:`tf.Tensor`
              number of atoms



      :Returns:

          :class:`python:dict`
              A dictionary that maps keys to values. It
              should contain key `natoms`











      ..
          !! processed by numpydoc !!


   .. py:property:: label_requirement
      :type: list[deepmd.utils.data.DataRequirementItem]


      
      Return data label requirements needed for this loss calculation.
















      ..
          !! processed by numpydoc !!


.. py:class:: EnerSpinLoss(starter_learning_rate: float, start_pref_e: float = 0.02, limit_pref_e: float = 1.0, start_pref_fr: float = 1000, limit_pref_fr: float = 1.0, start_pref_fm: float = 10000, limit_pref_fm: float = 10.0, start_pref_v: float = 0.0, limit_pref_v: float = 0.0, start_pref_ae: float = 0.0, limit_pref_ae: float = 0.0, start_pref_pf: float = 0.0, limit_pref_pf: float = 0.0, relative_f: Optional[float] = None, enable_atom_ener_coeff: bool = False, use_spin: Optional[list] = None)

   Bases: :py:obj:`deepmd.tf.loss.loss.Loss`


   
   The abstract class for the loss function.
















   ..
       !! processed by numpydoc !!

   .. py:attribute:: starter_learning_rate


   .. py:attribute:: start_pref_e
      :value: 0.02



   .. py:attribute:: limit_pref_e
      :value: 1.0



   .. py:attribute:: start_pref_fr
      :value: 1000



   .. py:attribute:: limit_pref_fr
      :value: 1.0



   .. py:attribute:: start_pref_fm
      :value: 10000



   .. py:attribute:: limit_pref_fm
      :value: 10.0



   .. py:attribute:: start_pref_v
      :value: 0.0



   .. py:attribute:: limit_pref_v
      :value: 0.0



   .. py:attribute:: start_pref_ae
      :value: 0.0



   .. py:attribute:: limit_pref_ae
      :value: 0.0



   .. py:attribute:: start_pref_pf
      :value: 0.0



   .. py:attribute:: limit_pref_pf
      :value: 0.0



   .. py:attribute:: relative_f
      :value: None



   .. py:attribute:: enable_atom_ener_coeff
      :value: False



   .. py:attribute:: use_spin
      :value: None



   .. py:attribute:: has_e


   .. py:attribute:: has_fr


   .. py:attribute:: has_fm


   .. py:attribute:: has_v


   .. py:attribute:: has_ae


   .. py:method:: build(learning_rate, natoms, model_dict, label_dict, suffix)

      
      Build the loss function graph.


      :Parameters:

          **learning_rate** : :obj:`tf.Tensor`
              learning rate

          **natoms** : :obj:`tf.Tensor`
              number of atoms

          **model_dict** : :class:`python:dict`\[:class:`python:str`, :obj:`tf.Tensor`]
              A dictionary that maps model keys to tensors

          **label_dict** : :class:`python:dict`\[:class:`python:str`, :obj:`tf.Tensor`]
              A dictionary that maps label keys to tensors

          **suffix** : :class:`python:str`
              suffix



      :Returns:

          :obj:`tf.Tensor`
              the total squared loss

          :class:`python:dict`\[:class:`python:str`, :obj:`tf.Tensor`]
              A dictionary that maps loss keys to more loss tensors











      ..
          !! processed by numpydoc !!


   .. py:method:: eval(sess, feed_dict, natoms)

      
      Eval the loss function.


      :Parameters:

          **sess** : :obj:`tf.Session`
              TensorFlow session

          **feed_dict** : :class:`python:dict`\[:obj:`tf.placeholder`, :obj:`tf.Tensor`]
              A dictionary that maps graph elements to values

          **natoms** : :obj:`tf.Tensor`
              number of atoms



      :Returns:

          :class:`python:dict`
              A dictionary that maps keys to values. It
              should contain key `natoms`











      ..
          !! processed by numpydoc !!


   .. py:method:: print_header()


   .. py:method:: print_on_training(tb_writer, cur_batch, sess, natoms, feed_dict_test, feed_dict_batch)


   .. py:property:: label_requirement
      :type: list[deepmd.utils.data.DataRequirementItem]


      
      Return data label requirements needed for this loss calculation.
















      ..
          !! processed by numpydoc !!


.. py:class:: EnerDipoleLoss(starter_learning_rate: float, start_pref_e: float = 0.1, limit_pref_e: float = 1.0, start_pref_ed: float = 1.0, limit_pref_ed: float = 1.0)

   Bases: :py:obj:`deepmd.tf.loss.loss.Loss`


   
   The abstract class for the loss function.
















   ..
       !! processed by numpydoc !!

   .. py:attribute:: starter_learning_rate


   .. py:attribute:: start_pref_e
      :value: 0.1



   .. py:attribute:: limit_pref_e
      :value: 1.0



   .. py:attribute:: start_pref_ed
      :value: 1.0



   .. py:attribute:: limit_pref_ed
      :value: 1.0



   .. py:method:: build(learning_rate, natoms, model_dict, label_dict, suffix)

      
      Build the loss function graph.


      :Parameters:

          **learning_rate** : :obj:`tf.Tensor`
              learning rate

          **natoms** : :obj:`tf.Tensor`
              number of atoms

          **model_dict** : :class:`python:dict`\[:class:`python:str`, :obj:`tf.Tensor`]
              A dictionary that maps model keys to tensors

          **label_dict** : :class:`python:dict`\[:class:`python:str`, :obj:`tf.Tensor`]
              A dictionary that maps label keys to tensors

          **suffix** : :class:`python:str`
              suffix



      :Returns:

          :obj:`tf.Tensor`
              the total squared loss

          :class:`python:dict`\[:class:`python:str`, :obj:`tf.Tensor`]
              A dictionary that maps loss keys to more loss tensors











      ..
          !! processed by numpydoc !!


   .. py:method:: eval(sess, feed_dict, natoms)

      
      Eval the loss function.


      :Parameters:

          **sess** : :obj:`tf.Session`
              TensorFlow session

          **feed_dict** : :class:`python:dict`\[:obj:`tf.placeholder`, :obj:`tf.Tensor`]
              A dictionary that maps graph elements to values

          **natoms** : :obj:`tf.Tensor`
              number of atoms



      :Returns:

          :class:`python:dict`
              A dictionary that maps keys to values. It
              should contain key `natoms`











      ..
          !! processed by numpydoc !!


   .. py:property:: label_requirement
      :type: list[deepmd.utils.data.DataRequirementItem]


      
      Return data label requirements needed for this loss calculation.
















      ..
          !! processed by numpydoc !!


