0

I am working on expanding a friend's PyTorch Deep Learning Program. The custom gym environment has 5 time steps, and I am looking to decouple the original neural network by time steps to see if that improves learning. As a result, I created 5 separate neural networks model_0, model_1, ..., model_4, and I want them to have the exact same architecture.

We have a python class to define the policy as follows:

class GreedyPolicy():
    def __init__(self, env, critic_init, exploration, step_size = 1, THETA_MIN = .1, THETA_MAX = 1.0):

        self.env = env
        self.name = 'GreedyPolicy'
        # There are other declarations here, but not important for the question.

    def _get_theta(self, critic): # input: object
    
        self.theta = np.zeros((self.env.observation_space.spaces[0].n * self.env.observation_space.spaces[1].n, self.env.action_space.n))
    
        for t in range(self.env.observation_space.spaces[0].n):
            for z in range(self.env.observation_space.spaces[1].n):
                state = t, z
                if t_separator:
                    if self.__name__ == model_0:
                        critic_values = [critic.CPTpredict(state, a) for a in np.arange(self.nA)]

Then, below, we defined the model and called on the above class GreedyPolicy, with QPG_CPT as a class to set up the neural network architecture:

if t_separator:
    model_0 = QPG_CPT(env, estimator_critic = FLRCritic, estimator_policy = GreedyPolicy, n_batch = n_batch, param_init = 0.0, critic_lr = critic_lr, step_size = step_size)

However, self.name in the second last line of the first part of the code refers to 'GreedyPolicy' instead of 'model_0'. Is there a way to do something similar to "if self.name == model_0:"?

Jin Siang
  • 1
  • 1
  • please [format](https://stackoverflow.com/help/formatting) your questions. It is difficult to read this way. – Shai Jan 09 '23 at 06:47

0 Answers0