torcheval.metrics.WordInformationPreserved¶
-
class
torcheval.metrics.
WordInformationPreserved
(*, device: Optional[device] = None)[source]¶ Compute the word information preserved of the predicted word sequence(s) with the reference word sequence(s). Its functional version is
torcheval.metrics.functional.word_information_preserved()
.Examples
>>> import torch >>> from torcheval.metrics import WordInformationPreserved
>>> metric = WordInformationPreserved() >>> metric.update(["this is the prediction", "there is an other sample"], ["this is the reference", "there is another one"]) >>> metric.compute() tensor(0.3472)
>>> metric = WordInformationPreserved() >>> metric.update(["hello world", "welcome to the facebook"], ["hello metaverse", "welcome to meta"]) >>> metric.compute() tensor(0.3)
-
__init__
(*, device: Optional[device] = None) None [source]¶ Initialize a metric object and its internal states.
Use
self._add_state()
to initialize state variables of your metric class. The state variables should be eithertorch.Tensor
, a list oftorch.Tensor
, or a dictionary withtorch.Tensor
as values
Methods
__init__
(*[, device])Initialize a metric object and its internal states. compute
()Return the word information preserved score. load_state_dict
(state_dict[, strict])Loads metric state variables from state_dict. merge_state
(metrics)Merge the metric state with its counterparts from other metric instances. reset
()Reset the metric state variables to their default value. state_dict
()Save metric state variables in state_dict. to
(device, *args, **kwargs)Move tensors in metric state variables to device. update
(input, target)Update the metric state with correct_total, predicted length and reference length. Attributes
device
The last input device of Metric.to()
.-