Ejemplo n.º 1
0
    def __init__(self, num_states, num_actions, args):
        self.args = args
        self.num_states = num_states
        self.num_actions = num_actions

        #Set 2 DNNs
        self.main_network = network.NAF_Network(self.num_states,
                                                self.num_actions,
                                                self.args.hidden_layer_size)
        self.target_network = network.NAF_Network(self.num_states,
                                                  self.num_actions,
                                                  self.args.hidden_layer_size)

        # initialize parameter vector
        filename = 'weight_4.pth'
        param = torch.load(filename, map_location='cpu')
        self.main_network.load_state_dict(param)

        #Output information about Actor network and Critic network
        print(self.main_network)

        self.target_network.load_state_dict(self.main_network.state_dict())

        #Set Optimizer
        self.optimizer = optim.Adam(self.main_network.parameters(),
                                    lr=self.args.lr)

        self.loss_func = nn.MSELoss()
Ejemplo n.º 2
0
    def __init__(self, num_states, num_actions, args):
        self.args = args
        self.num_states = num_states
        self.num_actions = num_actions
        
        #Set 4 DNNs
        self.network_1 = network.NAF_Network(self.num_states,self.num_actions,self.args.hidden_layer_size)
        self.network_2 = network.NAF_Network(self.num_states,self.num_actions,self.args.hidden_layer_size)
        self.network_3 = network.NAF_Network(self.num_states,self.num_actions,self.args.hidden_layer_size)
        self.network_4 = network.NAF_Network(self.num_states,self.num_actions,self.args.hidden_layer_size)

        #case1
        filename_1 ='weight_1.pth'
        filename_2 ='weight_2.pth'
        filename_3 ='weight_3.pth'
        filename_4 ='weight_4.pth'

        #case2
        #filename_1 ='weight_5.pth'
        #filename_2 ='weight_6.pth'
        #filename_3 ='weight_7.pth'
        #filename_4 ='weight_8.pth'

        #case3
        #filename_1 ='weight_1.pth'
        #filename_2 ='weight_6.pth'
        #filename_3 ='weight_7.pth'
        #filename_4 ='weight_8.pth'

        #case4
        #filename_1 ='weight_5.pth'
        #filename_2 ='weight_2.pth'
        #filename_3 ='weight_7.pth'
        #filename_4 ='weight_8.pth'

        #case5
        #filename_1 ='weight_1.pth'
        #filename_2 ='weight_2.pth'
        #filename_3 ='weight_7.pth'
        #filename_4 ='weight_8.pth'

        param_1 = torch.load(filename_1, map_location='cpu')
        param_2 = torch.load(filename_2, map_location='cpu')
        param_3 = torch.load(filename_3, map_location='cpu')
        param_4 = torch.load(filename_4, map_location='cpu')

        self.network_1.load_state_dict(param_1)
        self.network_2.load_state_dict(param_2)
        self.network_3.load_state_dict(param_3)
        self.network_4.load_state_dict(param_4)
Ejemplo n.º 3
0
    def __init__(self, num_states, num_actions, args):
        self.args = args
        self.num_states = num_states
        self.num_actions = num_actions

        self.network_1 = network.NAF_Network(self.num_states, self.num_actions,
                                             self.args.hidden_layer_size)
        self.network_2 = network.NAF_Network(self.num_states, self.num_actions,
                                             self.args.hidden_layer_size)

        filename_1 = 'weight_1.pth'
        filename_2 = 'weight_2.pth'

        param_1 = torch.load(filename_1, map_location='cpu')
        param_2 = torch.load(filename_2, map_location='cpu')

        self.network_1.load_state_dict(param_1)
        self.network_2.load_state_dict(param_2)
Ejemplo n.º 4
0
    def __init__(self, num_states, num_actions, args):
        self.args = args
        self.num_states = num_states
        self.num_actions = num_actions

        self.main_network = network.NAF_Network(self.num_states,
                                                self.num_actions,
                                                self.args.hidden_layer_size)

        filename = 'weight_1.pth'
        param = torch.load(filename, map_location='cpu')
        self.main_network.load_state_dict(param)
Ejemplo n.º 5
0
    def __init__(self, num_states, num_actions, args):
        self.args = args
        self.num_states = num_states
        self.num_actions = num_actions

        self.network_1 = network.NAF_Network(self.num_states, self.num_actions,
                                             self.args.hidden_layer_size)
        self.network_2 = network.NAF_Network(self.num_states, self.num_actions,
                                             self.args.hidden_layer_size)
        self.network_3 = network.NAF_Network(self.num_states, self.num_actions,
                                             self.args.hidden_layer_size)
        self.network_4 = network.NAF_Network(self.num_states, self.num_actions,
                                             self.args.hidden_layer_size)
        self.network_5 = network.NAF_Network(self.num_states, self.num_actions,
                                             self.args.hidden_layer_size)
        self.network_6 = network.NAF_Network(self.num_states, self.num_actions,
                                             self.args.hidden_layer_size)
        self.network_7 = network.NAF_Network(self.num_states, self.num_actions,
                                             self.args.hidden_layer_size)
        self.network_8 = network.NAF_Network(self.num_states, self.num_actions,
                                             self.args.hidden_layer_size)

        filename_1 = 'weight_1.pth'
        filename_2 = 'weight_2.pth'
        filename_3 = 'weight_3.pth'
        filename_4 = 'weight_4.pth'
        filename_5 = 'weight_5.pth'
        filename_6 = 'weight_6.pth'
        filename_7 = 'weight_7.pth'
        filename_8 = 'weight_8.pth'

        param_1 = torch.load(filename_1, map_location='cpu')
        param_2 = torch.load(filename_2, map_location='cpu')
        param_3 = torch.load(filename_3, map_location='cpu')
        param_4 = torch.load(filename_4, map_location='cpu')
        param_5 = torch.load(filename_5, map_location='cpu')
        param_6 = torch.load(filename_6, map_location='cpu')
        param_7 = torch.load(filename_7, map_location='cpu')
        param_8 = torch.load(filename_8, map_location='cpu')

        self.network_1.load_state_dict(param_1)
        self.network_2.load_state_dict(param_2)
        self.network_3.load_state_dict(param_3)
        self.network_4.load_state_dict(param_4)
        self.network_5.load_state_dict(param_5)
        self.network_6.load_state_dict(param_6)
        self.network_7.load_state_dict(param_7)
        self.network_8.load_state_dict(param_8)
Ejemplo n.º 6
0
    def __init__(self, num_states, num_actions, args):
        self.args = args
        self.num_states = num_states
        self.num_actions = num_actions

        #Set 2 DNNs
        self.main_network = network.NAF_Network(self.num_states,
                                                self.num_actions,
                                                self.args.hidden_layer_size)
        self.target_network = network.NAF_Network(self.num_states,
                                                  self.num_actions,
                                                  self.args.hidden_layer_size)

        #Output information about Actor network and Critic network
        print(self.main_network)

        self.target_network.load_state_dict(self.main_network.state_dict())

        #Set Optimizer
        self.optimizer = optim.Adam(self.main_network.parameters(),
                                    lr=self.args.lr)

        self.loss_func = nn.MSELoss()