Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Support visual environments #7

Closed
NathanGavenski opened this issue Nov 2, 2023 · 1 comment
Closed

[Feature] Support visual environments #7

NathanGavenski opened this issue Nov 2, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@NathanGavenski
Copy link
Owner

Currently, the code for all methods does not support CNN-based policies.

class Method(ABC):
    """Base class for all methods."""

    __version__ = "1.0.0"
    __author__ = "Nathan Gavenski"
    __method_name__ = "Abstract Method"

    def __init__(
        self,
        environment: Env,
        environment_parameters: Dict[str, Any],
        discrete_loss: nn.Module = nn.CrossEntropyLoss,
        continuous_loss: nn.Module = nn.MSELoss,
        optimizer_fn: optim.Optimizer = optim.Adam,
    ) -> None:
        """Initialize base class."""
        super().__init__()
        self.environment = environment
        self.discrete = isinstance(environment.action_space, spaces.Discrete)
        self.discrete |= isinstance(environment.action_space, gym_spaces.Discrete)
        self.device = "cuda" if torch.cuda.is_available() else "cpu"

        observation_size = environment.observation_space.shape[0]

        if self.discrete:
            action_size = environment.action_space.n
            self.loss_fn = discrete_loss()
        else:
            action_size = environment.action_space.shape[0]
            self.loss_fn = continuous_loss()

        self.policy = MLP(observation_size, action_size)

        self.optimizer_fn = optimizer_fn(
            self.policy.parameters(),
            **environment_parameters
        )

We should change to be more dynamic, but I want to avoid a register for all environments, whether they are visual- or vector-based states. However, I think this is gonna be solved once we reach Atari environments support.

@NathanGavenski
Copy link
Owner Author

Solved by #17

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant