Friday 6 September 2019

Can't import the encoder code for fine tunning GPT-2

I'm trying to reproduce the example from this article: https://medium.com/@ngwaifoong92/beginners-guide-to-retrain-gpt-2-117m-to-generate-custom-text-content-8bb5363d8b7f

The example code is from the following repo: https://github.com/nshepperd/gpt-2

After installing the requirements and downloading the model, the following step is to train the model, for which this code has to be executed:

python encode.py lyric.txt lyric.npz

The issue here is that this requires to import the following modules:

import argparse
import numpy as np

import encoder
from load_dataset import load_dataset

Where encoder and load_dataset are on a child directory:

|--encode.py
 --src
   |--encoder.py
   |--load_dataset.py

This generates the following error:

ModuleNotFoundError: No module named 'encoder'

I tried creating the __init__.py files and importing them as

src.encoder and src.load_dataset but that those not work either.

In the medium post the author proposes to move the file encoder.py to src and execute the code from there, the issue there is that doing it breaks the relative path for the model too and although I handled that the issue with the paths keeps going for other files as well.



from Can't import the encoder code for fine tunning GPT-2

No comments:

Post a Comment