11
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
import torch
|
||||
import torch.nn as nn
|
||||
|
||||
N_VEL = 2
|
||||
N_SUB = 2
|
||||
state_dim = N_VEL * N_SUB
|
||||
num_actions = 2 ** (N_SUB * N_VEL)
|
||||
M = 16
|
||||
|
||||
|
||||
class Net(nn.Module):
|
||||
def __init__(self, n_input_channels, n_actions):
|
||||
super(Net, self).__init__()
|
||||
self.conv1 = nn.Conv2d(in_channels=n_input_channels, out_channels=16, kernel_size=5, stride=1, padding=0)
|
||||
self.conv2 = nn.Conv2d(in_channels=16, out_channels=32, kernel_size=3, stride=1, padding=0)
|
||||
self.fc1 = nn.Linear(in_features=4 * 4 * 32, out_features=512)
|
||||
self.fc2 = nn.Linear(in_features=512, out_features=512)
|
||||
self.fc3 = nn.Linear(in_features=512, out_features=n_actions)
|
||||
# nn.init.normal_(self.fc1.weight, 0., 0.1)
|
||||
# nn.init.constant_(self.fc1.bias, 0.1)
|
||||
# self.fc2 = nn.Linear(500, 300)
|
||||
# nn.init.normal_(self.fc2.weight, 0., 0.1)
|
||||
# nn.init.constant_(self.fc2.bias, 0.1)
|
||||
# self.fc3 = nn.Linear(300, 250)
|
||||
# nn.init.normal_(self.fc3.weight, 0., 0.1)
|
||||
# nn.init.constant_(self.fc3.bias, 0.1)
|
||||
# self.fc4 = nn.Linear(250, n_actions)
|
||||
# nn.init.normal_(self.fc4.weight, 0., 0.1)
|
||||
# nn.init.constant_(self.fc4.bias, 0.1)
|
||||
|
||||
def forward(self, x):
|
||||
x = torch.sigmoid(self.conv1(x))
|
||||
x = torch.sigmoid(self.conv2(x))
|
||||
x = x.view(x.size(0), -1)
|
||||
x = torch.sigmoid(self.fc1(x))
|
||||
x = torch.sigmoid(self.fc2(x))
|
||||
output = self.fc3(x)
|
||||
return output
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
input_channels = 10 * 10 * 16
|
||||
num_actions = 16
|
||||
q_network = Net(input_channels, num_actions)
|
||||
|
||||
print(q_network)
|
||||
Reference in New Issue
Block a user