예제 #1
0
    def __init__(self, input_channels=4, activation_str='relu'):
        super().__init__()

        gain = nn.init.calculate_gain(activation_str)
        activation = activations_dict[activation_str]
        # (input_channels, 42, 42) -> (32, 4, 4)
        self.conv = nn.Sequential(
            init(nn.Conv2d(input_channels, 32, kernel_size=3, stride=2), gain=gain), activation(),
            init(nn.Conv2d(32, 32, kernel_size=3, stride=2), gain=gain), activation(),
            init(nn.Conv2d(32, 32, kernel_size=3, stride=2), gain=gain), activation()
        )
예제 #2
0
    def __init__(self, input_size, hidden_size):
        super().__init__()
        gain = nn.init.calculate_gain('leaky_relu', 0.2)

        self.net = nn.Sequential(
            init(nn.Linear(input_size, hidden_size), gain=gain),
            nn.LeakyReLU(0.2),
            init(nn.Linear(hidden_size, hidden_size), gain=gain),
            nn.LeakyReLU(0.2),
            init(nn.Linear(hidden_size, hidden_size), gain=gain),
            nn.LeakyReLU(0.2),
            init(nn.Linear(hidden_size, input_size), gain=0.1))
    def __init__(
            self,
            input_size, action_size,
            critic_size=1,
            detach_actor=False, detach_critic=False
    ):
        super().__init__()

        self.actor = init(nn.Linear(input_size, action_size), gain=0.01)
        self.critic = init(nn.Linear(input_size, critic_size))

        self.detach_actor = detach_actor
        self.detach_critic = detach_critic
예제 #4
0
 def __init__(self, input_channels=4, activation_str='relu'):
     super().__init__()
     gain = nn.init.calculate_gain(activation_str)
     activation = activations_dict[activation_str]
     # (input_channels, 96, 96) -> (256, 1, 1)
     self.conv = nn.Sequential(
         init(nn.Conv2d(input_channels, 8, kernel_size=4, stride=2), gain=gain), activation(),
         init(nn.Conv2d(8, 16, kernel_size=3, stride=2), gain=gain), activation(),
         init(nn.Conv2d(16, 32, kernel_size=3, stride=2), gain=gain), activation(),
         init(nn.Conv2d(32, 64, kernel_size=3, stride=2), gain=gain), activation(),
         init(nn.Conv2d(64, 128, kernel_size=3, stride=1), gain=gain), activation(),
         init(nn.Conv2d(128, 256, kernel_size=3, stride=1), gain=gain), activation()
     )