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

Scalar Torch Tensors cannot be loaded after serialization #1233

Open
sebffischer opened this issue Jan 15, 2025 · 0 comments · May be fixed by #1234
Open

Scalar Torch Tensors cannot be loaded after serialization #1233

sebffischer opened this issue Jan 15, 2025 · 0 comments · May be fixed by #1234

Comments

@sebffischer
Copy link
Collaborator

library(torch)
torch_load(torch_serialize(torch_tensor(1)))
#> torch_tensor
#>  1
#> [ CPUFloatType{1} ]
torch_load(torch_serialize(torch_scalar_tensor(1)))
#> Error in cpp_tensor_from_buffer(buffer, shape, list(dtype = dtype)): Not compatible with requested type: [type=list; target=double].

Created on 2025-01-15 with reprex v2.1.1

@dfalbel dfalbel linked a pull request Jan 15, 2025 that will close this issue
sebffischer added a commit to sebffischer/torch that referenced this issue Jan 15, 2025
fix(ignite): making state saveable, param_groups modifieable

It was impossible to save the state because of:

* mlverse#1233
* undefined tensors were part of the state such as
  max_exp_avg_sq for adam with amsgrad = FALSE.
  We now keep them as 0-sized tensors as undefined tensors
  are not serializeable.
  (The reason we keep them at all is that it simplifies the
   saving and loading of state dicts easier)

This PR also improves the tests by removing an unnecessary
call to `torch_manual_seed()` that made the tests deterministic
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant