import torch import torch.nn as nn import torch.nn.functional as F class PolicyNetwork(nn.Module): def __init__(self, input_dim, output_dim): super(PolicyNetwork, self).__init__() # Define the layers self.fc1 = nn.Linear(input_dim, 128) self.fc2 = nn.Linear(128, 128) self.fc3 = nn.Linear(128, output_dim) def forward(self, x): # Pass input through the layers with ReLU activation x = F.relu(self.fc1(x)) x = F.relu(self.fc2(x)) # Output layer with softmax to get probabilities x = F.softmax(self.fc3(x), dim=-1) return x