yandexdataschool / Practical_RL

A course in reinforcement learning in the wild

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

coursera/week5/reinforce assignment has inconsistent interface, preventing easy submission with PyTorch

HyoungsungKim opened this issue · comments

In TF, just passing generate_session to submit.py is enough.

But in pytorch version, there is train_on_session function which gets generate_session as parameter and this function works like generate_session in TF version.

Therefore, we have to define new submit function for pytorch.

# submit_torch.py
import sys
import numpy as np
sys.path.append("..")
import grading

def submit_cartpole(train_on_session, generate_session, email, token):
    sessions = [train_on_session(*generate_session()) for _ in range(100)]
    session_rewards = np.array(sessions)
    grader = grading.Grader("oyT3Bt7yEeeQvhJmhysb5g")    
    grader.set_answer("7QKmA", int(np.mean(session_rewards)))
    grader.submit(email, token)
from submit_torch import submit_cartpole

submit_cartpole(train_on_session, generate_session, <email>, <token>)

p.s. I don't know why but i couldn't define a new function in submit.py so i made new python file.

Technically, we don't yet support PyTorch on Coursera, although we are certainly planning that. You are free to submit solutions using it (as you have noticed, our graders are very flexible with regards to the implementation), but we'll probably be ironing out incompatibility issues later, when we migrate Coursera to PyTorch.

Thank you for consideration and I hope i can contribute pytorch migration later.

Really thanks for awesome contents :)

We have worked around the issue. Also, we've just merged #341 and announced support for PyTorch on Coursera! @HyoungsungKim willing to give it a try?

I'll keep this issue open since the interface is still inconsistent, so the problem isn't fixed yet.

Fixed in #431.