fixing small errors in train_agent_weights function