Comments (1)
class CategoricalPolicy(BasePolicy):
def __init__(self, config, network, env_spec, device, learn_V=False, **kwargs):
super().__init__(config=config, network=network, env_spec=env_spec, device=device, **kwargs)
if self.recurrent:
self.reset_rnn_states()
def __call__(self, x, out_keys=['action'], info={}, **kwargs):
if self.recurrent:
if 'mask' in info: # make the mask
mask = np.logical_not(info['mask']).astype(np.float32)
mask = torch.from_numpy(mask).unsqueeze(1).to(self.device)
else:
mask = None
out_network = self.network(x=x,
hidden_states=self.rnn_states,
mask=mask)
features = out_network['output']
# Update the tracking of current RNN hidden states
if 'rnn_state_no_update' not in info:
self.rnn_states = out_network['hidden_states']
class GaussianPolicy(BasePolicy):
def __init__(self,
config,
network,
env_spec,
device,
learn_V=False,
min_std=1e-6,
std_style='exp',
constant_std=None,
std_state_dependent=False,
init_std=1.0,
**kwargs):
super().__init__(config=config, network=network, env_spec=env_spec, device=device, **kwargs)
# Initialize and track the RNN hidden states
if self.recurrent:
self.reset_rnn_states()
def __call__(self, x, out_keys=['action'], info={}, **kwargs):
# Output dictionary
out_policy = {}
# Forward pass of feature networks to obtain features
if self.recurrent:
if 'mask' in info: # make the mask
mask = np.logical_not(info['mask']).astype(np.float32)
mask = torch.from_numpy(mask).unsqueeze(1).to(self.device)
else:
mask = None
out_network = self.network(x=x,
hidden_states=self.rnn_states,
mask=mask)
features = out_network['output']
# Update the tracking of current RNN hidden states
if 'rnn_state_no_update' not in info:
self.rnn_states = out_network['hidden_states']
from lagom.
Related Issues (20)
- Best way to test an agent ? HOT 4
- VAE Experiment uses old run_experiments function HOT 4
- the repo is very heavy HOT 5
- discrete RL examples HOT 1
- make baselines part of lagom HOT 7
- make mujoco an optional dependence HOT 2
- Numerical bug in RunningMeanVar
- Remove lz4 + atari-related when merged upstream to gym
- Merge seed and device into config object
- Replace from_numpy/tensorify with as_tensor, remove tensorify
- Integrate Ray as an additional backend for parallel experiments
- Migrate obs/reward normalization from env.wrappers into Agent itself
- Support Python 3.8
- Refactor Hyperparameter classes
- Logging: convert loaded loggings entirely into pandas `DataFrame`
- Extract independent snapshot functions for metrics: network, RL, experiment, statistics etc.
- Agent constructor: replace environment object as spec object
- Agent.choose_action: replace the mode string argument with internal self.training
- Use more fair RL evaluation metrics: IQM, Optimality Gap, Median, Mean
- [setup.py] get_version: replace `importlib` with raw text scanning
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lagom.