Closed cafletezbrant closed 8 months ago
thanks @cafletezbrant
this is pretty old code...
wouldn't this be sufficient? torch.linspace(1, input_dim, steps=hidden_dim)
@martinjankowiak pretty old
as in almost deprecated
? Or just not recently updated?
Also yes, I just tested, your proposal also works, can update to that if you'd prefer.
yes please use the simpler version, thanks!
pretty old as in almost deprecated? Or just not recently updated?
not recently updated and therefore oldish pytorch idioms
does arn.to(...)
work as expected?
Yes, arn.to()
works as expected:
arn.to('cpu')
next(arn.parameters()).is_cuda
# False
p = arn(x.cpu())
p.device
# device(type='cpu')
arn.to('cuda')
next(arn.parameters()).is_cuda
# True
p = arn(x)
p.device
# device(type='cuda', index=0)
p[0, 0:5]
# tensor([-0.2749, 0.0823, 0.1205, -0.1107, 0.1880], device='cuda:0',
# grad_fn=<SliceBackward0>)
I've pushed the requested simpler version. I was asking about age because if this is relatively unused code, I might expect to stub my toe a few more times, which might turn into one or more additional PRs.
not sure what your goals are but there are certainly more up-to-date normalizing flows libraries out there, some of which have some amount of pyro integration, see e.g. https://github.com/pyro-ppl/pyro/blob/dev/pyro/contrib/zuko.py
Ah interesting, is that a more recommended way to do things [1]? I was just trying to test out whether an NF would help my model fit (i.e. I am not sure if it will), which is why I was originally trying to use an AutoGuide. I suppose the way forward would be to simply write a guide using e.g. Zuko for the parameters I'm trying to estimate via NF and add that to my AutoGuideList?
[1] Just to be clear, I meant no criticism of the state of affairs of this code base, just that if it was less maintained than other parts, that I might be posting here again.
i think using the machinery in pyro is probably a reasonable place to start but if you want to explore a more diverse and/or more recent set of flows it may be a good idea to explore other pytorch-based flow libraries like zuko
Got it, thanks for the pointer. I'll explore the built-in work first and see where that goes.
looks like you deleted before i could merge
Sorry, brainfart! I will fix on Monday
Hi Pyro team, thank you for making such a useful and cool library. I encountered a small bug with an easy fix and wanted to share.
As described in my Pyro forum post, there is a device mismatch in
auto_reg_nn.sample_mask_indices()
. The linecreates tensors on CPU, even when
torch.set_default_device('cuda')
is used (I believe this is because torch.Tensor is an alias to torch.FloatTensor, which is not the same astorch.cuda.FloatTensor()
) . Minimum working example (from Pyro docs):The instantiation of a
AutoRegressiveNN
object will fail with the errorThe proposed fix is to replace
torch.Tensor().device
withtorch.tensor(0.0).device
(lower casetensor
; adding a simple value since torch.tensor() expects data). Then the object can be instantiated. This change is the sole element in this PR.