No problem @pointW - if you want to understand, A3C, there’s already a very good implementation in PyTorch,

  
      github.com
  
  
    ikostrikov/pytorch-a3c/blob/master/train.py 14
import torch
import torch.nn.functional as F
import torch.optim as optim
from torch.autograd import Variable

from envs import create_atari_env
from model import ActorCritic


def ensure_shared_grads(model, shared_model):
    for param, shared_param in zip(model.parameters(),
                                   shared_model.parameters()):
        if shared_param.grad is not None:
            return
        shared_param._grad = param.grad


def train(rank, args, shared_model, counter, lock, optimizer=None):
    torch.manual_seed(args.seed + rank)



  This file has been truncated. show original

  
  
    
    
  
  


This might be more complicated than you need if you only want plain policy gradient - but it works very well