-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8efcb31
commit 98494a0
Showing
6 changed files
with
786 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import torch | ||
from torch import nn | ||
|
||
|
||
|
||
|
||
class Network(nn.Module): # pragma: no cover | ||
def __init__(self, dim, layer_width): | ||
super().__init__() | ||
# Inputs to hidden layer linear transformation | ||
self.layer1 = nn.Linear(dim, layer_width) | ||
self.layer2 = nn.Linear(layer_width, layer_width) | ||
self.layer3 = nn.Linear(layer_width, dim) | ||
|
||
def forward(self, x): | ||
x = torch.Tensor(x) | ||
x = torch.nn.functional.relu(self.layer1(x)) | ||
x = torch.nn.functional.relu(self.layer2(x)) | ||
x = torch.nn.functional.relu(self.layer3(x)) | ||
return x.detach().numpy() | ||
|
||
def set_weights(self,w1,w2,w3): | ||
with torch.no_grad(): self.layer1.weight = nn.Parameter(torch.from_numpy(w1).float()) | ||
with torch.no_grad(): self.layer2.weight = nn.Parameter(torch.from_numpy(w2).float()) | ||
with torch.no_grad(): self.layer3.weight = nn.Parameter(torch.from_numpy(w3).float()) | ||
def set_biases(self,b1,b2,b3): | ||
with torch.no_grad(): self.layer1.bias = nn.Parameter(torch.from_numpy(b1).float()) | ||
with torch.no_grad(): self.layer2.bias = nn.Parameter(torch.from_numpy(b2).float()) | ||
with torch.no_grad(): self.layer3.bias = nn.Parameter(torch.from_numpy(b3).float()) | ||
|
||
def get_weights(self): | ||
return self.layer1.weight, self.layer2.weight, self.layer3.weight | ||
def get_biases(self): | ||
return self.layer1.bias, self.layer2.bias, self.layer3.bias |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
class GPlikelihood: # pragma: no cover | ||
def __init__(self, K, V): | ||
pass | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
class GPosterior: # pragma: no cover | ||
def __init__(self, KVinvY=None): | ||
assert isinstance(KVinvY, np.ndarray) | ||
|
Oops, something went wrong.