This commit is contained in:
JohnJim0816
2021-03-23 17:05:29 +08:00
parent bf0f2990cf
commit 5d8bf4802a
15 changed files with 117 additions and 74 deletions

View File

@@ -5,7 +5,7 @@ Author: John
Email: johnjim0816@gmail.com
Date: 2021-03-12 21:14:12
LastEditor: John
LastEditTime: 2021-03-20 16:44:00
LastEditTime: 2021-03-23 16:35:46
Discription:
Environment:
'''
@@ -13,24 +13,6 @@ import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.distributions import Categorical
class MLP1(nn.Module):
''' 多层感知机
输入state维度
输出:概率
'''
def __init__(self,n_states,hidden_dim = 36):
super(MLP1, self).__init__()
# 24和36为hidden layer的层数可根据state_dim, n_actions的情况来改变
self.fc1 = nn.Linear(n_states, hidden_dim)
self.fc2 = nn.Linear(hidden_dim,hidden_dim)
self.fc3 = nn.Linear(hidden_dim, 1) # Prob of Left
def forward(self, x):
x = F.relu(self.fc1(x))
x = F.relu(self.fc2(x))
x = F.sigmoid(self.fc3(x))
return x
class MLP2(nn.Module):
def __init__(self, n_states,n_actions,hidden_dim=128):