I'd like to change the .ipynb code written in jupyter notebook to .py.

Asked 2 years ago, Updated 2 years ago, 104 views

I am studying through a book called 'Deep Learning that I know and weave with Python blade coding'.

What I want to ask is how to transfer the code written on the jupyter notebook to the py code.

In this book, we use %run.../~~~~~ to run the ipynb file first and add code below it.

I wanted to fill it out in a py file, so I simply used import, but it didn't work.

The method adopted in the book above is

File name: /codes/chap05/mlp_model_test.ipynb

%run ../chap05/mlp_model.ipynb
%run ../chap05/dataset_chap123.ipynb
%run ../chap05/dataset_flower.ipynb

This is how you use run to run 3 files and write code below.

What I thought was,

File name: /codes/chap05/mlp_model_test.py

import mlp_model
import dataset_chap123
import dataset_flower

I thought it would work if I did this, but it didn't work. (All the imported files are py files.))

I'd appreciate it if you could tell me how to solve it.

If I may ask you an additional question, I used the method of registering class methods by declaring them externally in the ipynb file. Is it okay to do the same in the py file?

python jupyter-notebook vscode deep-learning

2022-09-21 11:52

1 Answers

I was also curious, so I searched for a well-organized document like below.

https://blueriver97.tistory.com/45


2022-09-21 11:52

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.