I am copying Python code from Jupyter Notebook to .py file to run it from a terminal. I could not find a way how this line should be implemented:
%%writefile -a submission.py
What is the same code in regular Python as %%writefile magic command does?
Replaced this:
%%writefile -a submission.py
model = Net()
model = model.float()
model.load_state_dict(state_dict)
model = model.to('cpu')
model = model.eval()
obs = tensor(obs['board']).reshape(1, 1, config.rows, config.columns).float()
obs = obs / 2
action = model(obs)
return int(action)
by this:
submission_ending = ''' model = Net()
model = model.float()
model.load_state_dict(state_dict)
model = model.to('cpu')
model = model.eval()
obs = tensor(obs['board']).reshape(1, 1, config.rows, config.columns).float()
obs = obs / 2
action = model(obs)
return int(action)'''
with open('submission.py', mode='a') as file:
file.write(submission_ending)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With