In the below code, please debug the error that, the log file is not created and no data…
- User
In the below code, please debug the error that, the log file is not created and no data were stored in the log file, I also need to clarify that i am using another log file in the subprogram snippet which is running during call function present in the below code(train part of the main code) where the log information were properly stored in that execution command in the subprogram snippet, but with in the main program train loop it doesnot working why? whether we need to use only one log file to store information either one of the code(either in sub program or at main program) And Also i am having the following errors, with in the directory 'OPAMP_GNNRL_log_file', the csv files 'rewards_log.csv' and 'losses_log.csv' were properly created and the required data were stored after the each episode loop finish, if we use 'with open('training_output/rewards.csv', 'w', newline='') as rewards_file, open('training_output/losses.csv', 'w', newline='') as losses_file, open(‘training_output/metrics.csv’, ‘w’, newline=‘’) as metrics_file:', instead of rewards_file = open('training_output/rewards.csv', 'w', newline='') losses_file = open('training_output/losses.csv', 'w', newline='') metrics_file = open('training_output/metrics.csv', 'w', newline='') with proper indent correction, then the first episode data only were stored in the 'rewards_log.csv' and 'losses_log.csv' csv files remaining episodes data were not stored so i changed the opening file with out using 'with'. one more error, with in the directory 'training_output', the csv files 'rewards.csv', 'losses.csv', and 'metrics.csv' were created but no data were stored as expected after finish each episodes. please debug the above said errors and update the program,
import pandas as pd import logging import os import csv
Basic configuration for logging
logging.basicConfig(filename='D:\OPAMP CIRCUITS\RL_GNN\agent_training.log', level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
class PPOAgent: def init(self, gnn_model, state_dim, action_space, lr_actor, lr_critic, gamma, gae_lambda, epsilon, policy_clip, epochs, entropy_coef): self.gamma = gamma self.gae_lambda = gae_lambda self.epsilon = epsilon self.policy_clip = policy_clip self.epochs = epochs self.entropy_coef = entropy_coef # Dynamic entropy coefficient
codeself.actor = Actor(gnn_model) self.critic = Critic() self.optimizer_actor = optim.Adam(self.actor.parameters(), lr=lr_actor) self.optimizer_critic = optim.Adam(self.critic.parameters(), lr=lr_critic) self.action_space = action_space # Assume continuous self.log_dir = 'OPAMP_GNNRL_log_file' os.makedirs(self.log_dir, exist_ok=True) - Assistant
- User
- Assistant