This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from pymeasure.adapters import VISAAdapter | |
| from pyvisa.errors import VisaIOError | |
| import re | |
| import logging | |
| log = logging.getLogger(__name__) | |
| log.addHandler(logging.NullHandler()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import numpy as np | |
| from rl.core import Processor | |
| from rl.util import WhiteningNormalizer | |
| class MultiInputProcessor(Processor): | |
| """Converts observations from an environment with multiple observations for use in a neural network | |
| policy. | |
| In some cases, you have environments that return multiple different observations per timestep | |
| (in a robotics context, for example, a camera may be used to view the scene and a joint encoder may |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import math | |
| import gym | |
| from gym import spaces, logger | |
| from gym.utils import seeding | |
| import numpy as np | |
| class CartPoleMultidictEnv(gym.Env): | |
| metadata = { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class MultiInputProcessor(Processor): | |
| """Converts observations from an environment with multiple observations for use in a neural network | |
| policy. | |
| In some cases, you have environments that return multiple different observations per timestep | |
| (in a robotics context, for example, a camera may be used to view the scene and a joint encoder may | |
| be used to report the angles for each joint). Usually, this can be handled by a policy that has | |
| multiple inputs, one for each modality. However, observations are returned by the environment | |
| in the form of a tuple `[(modality1_t, modality2_t, ..., modalityn_t) for t in T]` but the neural network | |
| expects them in per-modality batches like so: `[[modality1_1, ..., modality1_T], ..., [[modalityn_1, ..., modalityn_T]]`. |