2016-06-15 4 views
1

Ich habe vor kurzem den Code von Tensorflow VGG16 testen. Wenn ich vgg16.npy in python3.4 lade. Es kommt der Fehler heraus. Der Code ist wie folgt:load .npy Datei in Python3.4 Fehler

self.data_dict = np.load(vgg16_npy_path, encoding='latin1').item() 

Der Fehler:

TypeError: load() got an unexpected keyword argument 'encoding' 

Aber ich encoding='latin1' löschen, nur

self.data_dict = np.load(vgg16_npy_path).item() 

Es gibt auch einen Fehler kommt:

File "/home/kang/Documents/work_code_PC1/tensorflow-vgg/vgg16.py", line 20, in __init__ 
    self.data_dict = np.load(vgg16_npy_path).item() 

    File "/usr/lib/python3/dist-packages/numpy/lib/npyio.py", line 394, in load 
    return format.read_array(fid) 

    File "/usr/lib/python3/dist-packages/numpy/lib/format.py", line 446, in read_array 
    array = pickle.load(fp) 

UnicodeDecodeError: 'ascii' codec can't decode byte 0xed in position 0: ordinal not in range(128) 

Also, wie np.load zu laden. Npy Datei in Python3.4? Vielen Dank.

Antwort

1

Es scheint, dass Sie eine alte Version von NumPy für Python 3.4 installiert haben. Soweit ich das beurteilen kann, wurde das encoding Argument zu np.load() zwischen version 1.9.0 und version 1.9.1 hinzugefügt. Versuchen Sie, auf eine neuere Version von NumPy zu aktualisieren:

$ sudo pip3 install --upgrade numpy 
# ...or, if the above doesn't work on your platform: 
$ sudo pip install --upgrade numpy 
Verwandte Themen