Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The annotation of the parameter device of PyTorchPredictor is incomplete #3091

Closed
wu462 opened this issue Dec 26, 2023 · 2 comments · Fixed by #3094
Closed

The annotation of the parameter device of PyTorchPredictor is incomplete #3091

wu462 opened this issue Dec 26, 2023 · 2 comments · Fixed by #3094
Labels
bug Something isn't working enhancement New feature or request

Comments

@wu462
Copy link

wu462 commented Dec 26, 2023

Description

The annotation of the parameter device of PyTorchPredictor is incomplete, it should be Union[str, torch.device]

To Reproduce

class PyTorchPredictor(RepresentablePredictor):
    @validated()
    def __init__(
        self,
        input_names: List[str],
        prediction_net: nn.Module,
        batch_size: int,
        prediction_length: int,
        input_transform: Transformation,
        forecast_generator: ForecastGenerator = SampleForecastGenerator(),
        output_transform: Optional[OutputTransform] = None,
        lead_time: int = 0,
        device: str = "auto",
    ) -> None:

Error message or code output

pydantic.v1.error_wrappers.ValidationError: 1 validation error for PyTorchPredictorModel
device
  str type expected (type=type_error.str)
@wu462 wu462 added the bug Something isn't working label Dec 26, 2023
@lostella
Copy link
Contributor

For convenience, this is the line in question

device: str = "auto",

@cooling-0
Copy link

Thank youuuuuuuuuuuuuuuuuuu!
I had the same issue.
But thanks to your question I fixed it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants