Skip to content

Replace all torch.Tensor by torch.tensor #2527

@vfdev-5

Description

@vfdev-5

📚 Documentation

@sdesrozis it is incorrect to create tensors with torch.Tensor and should be replaced by torch.tensor.

Binary case
.. testcode:: 1
metric = Accuracy()
metric.attach(default_evaluator, "accuracy")
y_true = torch.Tensor([1, 0, 1, 1, 0, 1])
y_pred = torch.Tensor([1, 0, 1, 0, 1, 1])
state = default_evaluator.run([[y_pred, y_true]])
print(state.metrics["accuracy"])

This way we wont need neither cast to .long : y_true = torch.Tensor([2, 0, 2, 1, 0, 1]).long()

y_true = torch.Tensor([2, 0, 2, 1, 0, 1]).long()

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions