Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self, config, env, device, **kwargs):
super().__init__(**kwargs)
self.config = config
self.env = env
self.device = device
self.feature_layers = make_fc(flatdim(env.observation_space), config['nn.sizes'])
for layer in self.feature_layers:
ortho_init(layer, nonlinearity='relu', constant_bias=0.0)
self.layer_norms = nn.ModuleList([nn.LayerNorm(hidden_size) for hidden_size in config['nn.sizes']])
self.to(self.device)
def __init__(self, config, device, **kwargs):
super().__init__(**kwargs)
self.config = config
self.device = device
self.encoder = make_fc(784, [400])
for layer in self.encoder:
ortho_init(layer, nonlinearity='relu', constant_bias=0.0)
self.mean_head = nn.Linear(400, config['nn.z_dim'])
ortho_init(self.mean_head, weight_scale=0.01, constant_bias=0.0)
self.logvar_head = nn.Linear(400, config['nn.z_dim'])
ortho_init(self.logvar_head, weight_scale=0.01, constant_bias=0.0)
self.decoder = make_fc(config['nn.z_dim'], [400])
for layer in self.decoder:
ortho_init(layer, nonlinearity='relu', constant_bias=0.0)
self.x_head = nn.Linear(400, 784)
ortho_init(self.x_head, nonlinearity='sigmoid', constant_bias=0.0)
self.to(device)
self.total_iter = 0
def __init__(self, config, device, **kwargs):
super().__init__(**kwargs)
self.config = config
self.device = device
self.encoder = make_fc(784, [400])
for layer in self.encoder:
ortho_init(layer, nonlinearity='relu', constant_bias=0.0)
self.mean_head = nn.Linear(400, config['nn.z_dim'])
ortho_init(self.mean_head, weight_scale=0.01, constant_bias=0.0)
self.logvar_head = nn.Linear(400, config['nn.z_dim'])
ortho_init(self.logvar_head, weight_scale=0.01, constant_bias=0.0)
self.decoder = make_fc(config['nn.z_dim'], [400])
for layer in self.decoder:
ortho_init(layer, nonlinearity='relu', constant_bias=0.0)
self.x_head = nn.Linear(400, 784)
ortho_init(self.x_head, nonlinearity='sigmoid', constant_bias=0.0)
self.to(device)
self.total_iter = 0
def __init__(self, config, env, device, **kwargs):
super().__init__(**kwargs)
self.config = config
self.env = env
self.device = device
self.feature_layers = make_fc(flatdim(env.observation_space), config['nn.sizes'])
for layer in self.feature_layers:
ortho_init(layer, nonlinearity='relu', constant_bias=0.0)
self.layer_norms = nn.ModuleList([nn.LayerNorm(hidden_size) for hidden_size in config['nn.sizes']])
self.to(self.device)
def __init__(self, config, env, device, **kwargs):
super().__init__(**kwargs)
self.config = config
self.env = env
self.device = device
self.feature_layers = make_fc(flatdim(env.observation_space), [256, 256])
self.action_head = TanhDiagGaussianHead(256, flatdim(env.action_space), device, **kwargs)
self.to(device)
def __init__(self, config, env, device, **kwargs):
super().__init__(**kwargs)
self.config = config
self.env = env
self.device = device
# Q1
self.first_feature_layers = make_fc(flatdim(env.observation_space) + flatdim(env.action_space), [256, 256])
self.first_Q_head = nn.Linear(256, 1)
# Q2
self.second_feature_layers = make_fc(flatdim(env.observation_space) + flatdim(env.action_space), [256, 256])
self.second_Q_head = nn.Linear(256, 1)
self.to(self.device)
def __init__(self, config, env, device, **kwargs):
super().__init__(**kwargs)
self.config = config
self.env = env
self.device = device
# Q1
self.first_feature_layers = make_fc(flatdim(env.observation_space) + flatdim(env.action_space), [256, 256])
self.first_Q_head = nn.Linear(256, 1)
# Q2
self.second_feature_layers = make_fc(flatdim(env.observation_space) + flatdim(env.action_space), [256, 256])
self.second_Q_head = nn.Linear(256, 1)
self.to(self.device)
def __init__(self, config, env, device, **kwargs):
super().__init__(**kwargs)
self.config = config
self.env = env
self.device = device
self.feature_layers = make_fc(flatdim(env.observation_space), [256, 256])
self.mean_head = nn.Linear(256, flatdim(env.action_space))
self.logstd_head = nn.Linear(256, flatdim(env.action_space))
self.to(device)
def __init__(self, config, env, device, **kwargs):
super().__init__(**kwargs)
self.config = config
self.env = env
self.device = device
self.feature_layers = make_fc(flatdim(env.observation_space), [400, 300])
self.action_head = nn.Linear(300, flatdim(env.action_space))
assert np.unique(env.action_space.high).size == 1
assert -np.unique(env.action_space.low).item() == np.unique(env.action_space.high).item()
self.max_action = env.action_space.high[0]
self.to(self.device)
def __init__(self, config, env, device, **kwargs):
super().__init__(**kwargs)
self.config = config
self.env = env
self.device = device
# Q1
self.first_feature_layers = make_fc(flatdim(env.observation_space) + flatdim(env.action_space), [400, 300])
self.first_Q_head = nn.Linear(300, 1)
# Q2
self.second_feature_layers = make_fc(flatdim(env.observation_space) + flatdim(env.action_space), [400, 300])
self.second_Q_head = nn.Linear(300, 1)
self.to(self.device)