Git Product home page Git Product logo

il-datasets's Introduction

Hi there ๐Ÿ‘‹

I'm Nathan, a PhD student at King's College London. My research involves imitation learning and some other topics related to machine learning. Most of my papers have a public repository! So, if you are interested in any of them, please check my pinned repos.

Before being a researcher, I was a software developer at ADP Brazil Labs and a quality analyst at IBM. I really enjoy creating things. Sometimes I'll have random repositories that make no sense.


My GitHub stats

Nathan's GitHub stats

il-datasets's People

Contributors

nathangavenski avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

il-datasets's Issues

[BUG] metrics doesn't make sure that all inputs on the same device.

If prediction and ground truth are on different devices it will brake

def accuracy(prediction: Tensor, ground_truth: Tensor) -> Number:
    """Compute the accuracy for a model. The accuracy returned is the percentage from 0 to 100.

    Args:
        prediction (torch.Tensor): logits from a model.
        ground_truth (torch.Tensor): ground truth class.

    Raises:
        ValueError: if predictions and ground_truth are not torch.Tensor.
        ValueError: if predictions are not two dimensional.
        ValueError: if ground_truth is not one dimensional.

    Returns:
        accuracy (Number): accuracy between 0 and 100 for a model.
    """

    if not isinstance(prediction, Tensor) or not isinstance(ground_truth, Tensor):
        raise ValueError("'prediction' and 'ground truth' should be a tensor")

    if len(prediction.size()) != 2:
        raise ValueError("'prediction' and 'ground truth' need to be 2 dimensional.")

    if len(ground_truth.size()) != 1:
        raise ValueError("'ground truth' need to be 1 dimensional.")

    return ((argmax(prediction, 1) == ground_truth).sum().item() / ground_truth.size(0)) * 100

PyPi dependencies

When installing the il-dataset package it downloads a lot of other packages alongside. It should be more clean an faster to run. Moreover, it is downloading CUDA packages when there is no GPU usage.

| Collecting networkx (from torch->il-datasets)
|   Downloading networkx-3.1-py3-none-any.whl (2.1 MB)
     โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” 2.1/2.1 MB 10.0 MB/s eta 0:00:00
| Collecting jinja2 (from torch->il-datasets)
|   Downloading Jinja2-3.1.2-py3-none-any.whl (133 kB)
     โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” 133.1/133.1 kB 7.4 MB/s eta 0:00:00
| Collecting nvidia-cuda-nvrtc-cu11==11.7.99 (from torch->il-datasets)
|   Downloading nvidia_cuda_nvrtc_cu11-11.7.99-2-py3-none-manylinux1_x86_64.whl (21.0 MB)
     โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” 21.0/21.0 MB 9.9 MB/s eta 0:00:00
| Collecting nvidia-cuda-runtime-cu11==11.7.99 (from torch->il-datasets)
|   Downloading nvidia_cuda_runtime_cu11-11.7.99-py3-none-manylinux1_x86_64.whl (849 kB)
     โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” 849.3/849.3 kB 11.8 MB/s eta 0:00:00
| Collecting nvidia-cuda-cupti-cu11==11.7.101 (from torch->il-datasets)
|   Downloading nvidia_cuda_cupti_cu11-11.7.101-py3-none-manylinux1_x86_64.whl (11.8 MB)
     โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” 11.8/11.8 MB 9.4 MB/s eta 0:00:00
| Collecting nvidia-cudnn-cu11==8.5.0.96 (from torch->il-datasets)
|   Downloading nvidia_cudnn_cu11-8.5.0.96-2-py3-none-manylinux1_x86_64.whl (557.1 MB)
     โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” 557.1/557.1 MB 4.6 MB/s eta 0:00:00

[Feature] Support visual environments

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.

[Feature] Support vectorized environments on GymWrapper

As for now, _enjoy runs 10 sequential episodes, which can be really slow.

def step(
      self,
      action: Union[float, int]
) -> Union[
  Tuple[List[float], float, bool, bool, Dict[str, Any]],
  Tuple[List[float], float, bool, Dict[str, Any]]
]:
  """
  Perform an action in the environment and return the appropriate return
  according to version.
  """
  gym_return = self.env.step(action)
  if self.version == "newest":
      state, reward, terminated, truncated, info = gym_return
      return state, reward, terminated or truncated, info

  return gym_return

The or function will not work because the vectorized version will return a list.


We should support vectorized environments or run the Controller class to make it faster. Probably running the Controller class would be easier and allow for more scalability. The Controller class save into files, which would need some workaround. However, we already do something similar for unit testing.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.