IniziaInizia gratis

Environment and neural network setup

You'll begin by setting up the environment you'll use throughout the course: the Lunar Lander environment, where an agent controls the thrusters for a vehicle attempting to land on the moon.

torch, torch.nn, torch.optim and gym are imported into your exercises.

Questo esercizio fa parte del corso

Deep Reinforcement Learning in Python

Visualizza il corso

Istruzioni dell'esercizio

  • Initialize the Lunar Lander environment in gym (LunarLander-v2).
  • Define a single linear transformation layer, with input dimension dim_inputs and output dimension dim_outputs.
  • Instantiate the Neural Network for input dimension 8 and output dimension 4.
  • Provide the Adam optimizer with the parameters.

Esercizio pratico interattivo

Prova a risolvere questo esercizio completando il codice di esempio.

# Initiate the Lunar Lander environment
env = gym.____

class Network(nn.Module):
    def __init__(self, dim_inputs, dim_outputs):
        super(Network, self).__init__()
        # Define a linear transformation layer 
        self.linear = ____
    def forward(self, x):
        return self.linear(x)

# Instantiate the network
network = ____

# Initialize the optimizer
optimizer = optim.Adam(____, lr=0.0001)

print("Network initialized as:\n", network)
Modifica ed esegui il codice