Ax: warning issued for example on homepage

Created on 1 Oct 2020  路  5Comments  路  Source: facebook/Ax

/Users/petercotton/virtual-envs/tuneup/lib/python3.7/site-packages/ax/modelbridge/torch.py:311: UserWarning:
To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor).

Reproduce:
https://github.com/microprediction/tuneup/blob/master/tests/test_ax.py

bug fixready

All 5 comments

Hmm, I can take a deeper look into this, but at first glance this warning actually seems a bit faulty. This line constructs from a numpy array, not copy construction from a tensor. In any case, this behavior should be safe.

@sdsingh are we sure this is a np array? Or are we believing the typing too much here? Seems quite plausible that this may be called on a Tensor / Tensoray somewhere.

Hmm, that's plausible. Given that this is the NumpyModelBridge, we really shouldn't make this call on Tensor. I'll take a deeper look.

@Balandat, you're correct, in prediction the numpy array (observation features) is actually transformed twice. Hopefully it's an easy fix, looking into it.

@microprediction, I have confirmed that this warning is, indeed, just a warning, and should not affect behavior/performance.

The fix is now in the latest stable, 0.1.18.

Was this page helpful?
0 / 5 - 0 ratings