Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
def test_trainer_composition_model(tmp_path: Path) -> None: for param in chgnet.composition_model.parameters(): assert param.requires_grad is False trainer = Trainer( model=chgnet, targets="efsm", optimizer="Adam", criterion="MSE", learning_rate=1e-2, epochs=5, ) initial_weights = chgnet.composition_model.state_dict()["fc.weight"].clone() > trainer.train( train_loader, val_loader, save_dir=tmp_path, train_composition_model=True ) tests/test_trainer.py:106: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ chgnet/trainer/trainer.py:305: in train train_mae = self._train(train_loader, epoch, wandb_log_freq) chgnet/trainer/trainer.py:400: in _train combined_loss = self.criterion(targets, prediction) ../../.venv/py312/lib/python3.12/site-packages/torch/nn/modules/module.py:1553: in _wrapped_call_impl return self._call_impl(*args, **kwargs) ../../.venv/py312/lib/python3.12/site-packages/torch/nn/modules/module.py:1562: in _call_impl return forward_call(*args, **kwargs) chgnet/trainer/trainer.py:861: in forward if mag_target is not None and not np.isnan(mag_target).any(): _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = tensor([0.9620, 0.0657], device='mps:0'), dtype = None def __array__(self, dtype=None): if has_torch_function_unary(self): return handle_torch_function(Tensor.__array__, (self,), self, dtype=dtype) if dtype is None: > return self.numpy() E TypeError: can't convert mps:0 device type tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first. ../../.venv/py312/lib/python3.12/site-packages/torch/_tensor.py:1083: TypeError
- Loading branch information