neuralmonkey.trainers.objective module¶
-
class
neuralmonkey.trainers.objective.
CostObjective
(decoder: neuralmonkey.model.model_part.GenericModelPart, weight: Union[tensorflow.python.framework.ops.Tensor, float, NoneType] = None) → None¶ Bases:
neuralmonkey.trainers.objective.Objective
Cost objective class.
This class represent objectives that are based directly on a cost attribute of any compatible model part.
-
__init__
(decoder: neuralmonkey.model.model_part.GenericModelPart, weight: Union[tensorflow.python.framework.ops.Tensor, float, NoneType] = None) → None¶ Construct a new instance of the CostObjective class.
Parameters: - decoder – A GenericModelPart instance that has a cost attribute.
- weight – The weight of the objective.
Raises: - TypeError when the decoder argument does not have the cost
attribute.
-
loss
¶ Return the loss tensor fetched by the trainer.
-
weight
¶ Return the weight of this objective.
The loss will be multiplied by this so the gradients can be controlled in case of multiple objectives.
Returns: An optional tensor. If None, default weight of 1 is assumed.
-
-
class
neuralmonkey.trainers.objective.
Objective
(name: str, decoder: MP) → None¶ Bases:
typing.Generic
The training objective base class.
-
__init__
(name: str, decoder: MP) → None¶ Construct the objective.
Parameters: name – The name for the objective. This will be used e.g. in TensorBoard.
-
decoder
¶ Get the decoder used by the objective.
-
gradients
¶ Manually specified gradients - useful for reinforcement learning.
-
loss
¶ Return the loss tensor fetched by the trainer.
-
name
¶ Get the name of the objective.
-
weight
¶ Return the weight of this objective.
The loss will be multiplied by this so the gradients can be controlled in case of multiple objectives.
Returns: An optional tensor. If None, default weight of 1 is assumed.
-