Skip to content

Commit e82dadc

Browse files
authored
Update rnnrbm.py
Hi, so I ran into this error at line 244, then I traced back the error it was due to at line 291, os.path.dirname(__file__) returned empty string and caused the split-out parent directory to be empty, thus the path argument passed into train() function became ./data/Nottingham/train/*.mid which did not exist rather than ../data/Nottingham/train/* which was expected. So I changed os.path.dirname(__file__) into os.path.dirname(os.path.abspath(__file__)) to get the current working directory from file's absolute path, by which you could then split out the parent directory. You can refer the reason to this link: https://stackoverflow.com/questions/7783308/os-path-dirname-file-returns-empty
1 parent 8bd8a5a commit e82dadc

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

code/rnnrbm.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,8 @@ def generate(self, filename, show=True):
288288

289289
def test_rnnrbm(batch_size=100, num_epochs=200):
290290
model = RnnRbm()
291-
re = os.path.join(os.path.split(os.path.dirname(__file__))[0],
291+
cwd = os.path.dirname(os.path.abspath(__file__))
292+
re = os.path.join(os.path.split(cwd)[0],
292293
'data', 'Nottingham', 'train', '*.mid')
293294
model.train(glob.glob(re),
294295
batch_size=batch_size, num_epochs=num_epochs)

0 commit comments

Comments
 (0)