Issue
This is the neural network that I defined
class generator(nn.Module):
def __init__(self, n_dim, io_dim):
super().__init__()
self.gen = nn.Sequential(
nn.Linear(n_dim,64),
nn.LeakyReLU(.01),
nn.Linear(64, io_dim),
)
def forward(self, x):
return self.gen(x)
#The input x is:
x = numpy.random.dirichlet([10,6,3],3)
Now I want the neural network to take dirichlet distributed samples (sampled using numpy.random.dirichlet([10,6,3],10) ) as an input. How to do that?
Solution
Instead of using numpy to sample from a dirichlet distribution, use pytorch. Here is the code:
y = torch.Tensor([[10,6,3]])
m = torch.distributions.dirichlet.Dirichlet(y)
z=m.sample()
gen = generator(3,3)
gen(z)
Answered By - Anik Chaudhuri
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.