How to use the lagom.networks.make_fc function in lagom

To help you get started, we’ve selected a few lagom examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github zuoxingdong / lagom / examples / reinforcement_learning / ppo / logs / compare_tanh_and_relu_plus_layernorm / relu+layernorm / source_files / agent.py View on Github external
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)
github zuoxingdong / lagom / examples / vae / model.py View on Github external
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
github zuoxingdong / lagom / examples / vae / model.py View on Github external
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
github zuoxingdong / lagom / baselines / vpg / logs / default / source_files / agent.py View on Github external
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)
github zuoxingdong / lagom / baselines / sac / logs / _old_default / source_files / _agent.py View on Github external
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)
github zuoxingdong / lagom / baselines / sac / logs / _default / source_files / agent.py View on Github external
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)
github zuoxingdong / lagom / baselines / sac / logs / _old_default / source_files / _agent.py View on Github external
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)
github zuoxingdong / lagom / baselines / sac / agent.py View on Github external
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)
github zuoxingdong / lagom / baselines / ddpg / logs / default / source_files / agent.py View on Github external
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)
github zuoxingdong / lagom / examples / reinforcement_learning / td3 / agent.py View on Github external
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)