Conversion of torch.Tensor to numpy object #62
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Due to the possibility of
x[1]
being of typetorch.Tensor
, thenp.mean(...)
call fails with anAttributeError: torch.dtype object has no attribute type
.The full error is
[ERROR 03:50:05] pymarl Failed after 0:01:46! Traceback (most recent calls WITHOUT Sacred internals): File "src/main.py", line 35, in my_main run(_run, config, _log) File "/home/minerva/Projects/multiagentrl/pymarl/src/run.py", line 48, in run run_sequential(args=args, logger=logger) File "/home/minerva/Projects/multiagentrl/pymarl/src/run.py", line 209, in run_sequential logger.print_recent_stats() File "/home/minerva/Projects/multiagentrl/pymarl/src/utils/logging.py", line 48, in print_recent_stats item = "{:.4f}".format(np.mean([x[1] for x in self.stats[k][-window:]])) File "<__array_function__ internals>", line 6, in mean File "/home/minerva/anaconda3/envs/mpe/lib/python3.6/site-packages/numpy/core/fromnumeric.py", line 3335, in mean out=out, **kwargs) File "/home/minerva/anaconda3/envs/mpe/lib/python3.6/site-packages/numpy/core/_methods.py", line 161, in _mean ret = ret.dtype.type(ret / rcount) AttributeError: 'torch.dtype' object has no attribute 'type' [INFO 03:50:05] absl Shutdown gracefully. [INFO 03:50:05] absl Shutdown with return code: -15