MCPcopy Create free account
hub / github.com/ddbourgin/numpy-ml / __init__

Method __init__

numpy_ml/tests/nn_torch_models.py:1530–1542  ·  view source on GitHub ↗
(self, n_in, n_hid, act_fn, params, **kwargs)

Source from the content-addressed store, hash-verified

1528
1529class TorchFCLayer(nn.Module):
1530 def __init__(self, n_in, n_hid, act_fn, params, **kwargs):
1531 super(TorchFCLayer, self).__init__()
1532 self.layer1 = nn.Linear(n_in, n_hid)
1533
1534 # explicitly set weights and bias
1535 # NB: we pass the *transpose* of the weights to pytorch, meaning
1536 # we'll need to check against the *transpose* of our outputs for
1537 # any function of the weights
1538 self.layer1.weight = nn.Parameter(torch.FloatTensor(params["W"].T))
1539 self.layer1.bias = nn.Parameter(torch.FloatTensor(params["b"]))
1540
1541 self.act_fn = act_fn
1542 self.model = nn.Sequential(self.layer1, self.act_fn)
1543
1544 def forward(self, X):
1545 self.X = X

Callers

nothing calls this directly

Calls 1

__init__Method · 0.45

Tested by

no test coverage detected