ニューラルネットワークを用いた機械学習のプログラムなのですが、
target[nFiles] = int(subdir[-1])-1
の部分がなにを示しているのかわかりません。
実行すると
Traceback (most recent call last):
File "C:\python\NN\mlp_cg.py", line 218, in <module>
target[nFiles] = int(subdir[-1])-1
ValueError: invalid literal for int() with base 10: '0deg_30deg_0811\sleep1'
と、この部分で怒られています。ちなみにpathの部分は
path = '/data/0deg_30deg_0811'
となっています。
nFiles = 0 for root, dirs, files in os.walk(path): # print 'Directory: %s' % root subdir = root.split('/') if subdir[-1] == 'sleep1': continue nsubFiles = 0 for f in files: #print '%d' % int(subdir[-1]) target[nFiles] = int(subdir[-1])-1 r,e = os.path.splitext(f) if e.lower() == '.png': # print '%s' % root+'/'+f img = imresize(imread(root+'/'+f), (height,width), interp='bilinear') image = np.asarray(img, dtype=np.float32) image /= 255.0 # scale uint8 coded colors to the [0.0, 1.0] floats images[nFiles, ...] = image nFiles += 1 nsubFiles += 1 if nsubFiles != 0: print '%d files found in %s.' % (nsubFiles, root.split('/')[-1]) print 'Total: %d files found in %s.' % (nFiles, path)
回答1件
あなたの回答
tips
プレビュー