0

Ich möchte mein Bild mischen, bevor Sie es in die hdf5-Datei, aber einen Fehler in der Berechnung. Als neuer Lerner kann ich das nicht einmal nach dem Lesen der hdf5-Dokumentation herausfinden. Bitte führe mich.Problem mit Shuffling Bild zu einer HDF5-Datei

from random import shuffle 
import glob 
shuffle_data = True # shuffle the addresses before saving 

hdf5_path = 'Cat vs Dog/dataset.hdf5' # address to where you want to save the hdf5 file 
cat_dog_train_path = 'Cat vs Dog/train/*.jpg' 

# read addresses and labels from the 'train' folder 
addrs = glob.glob(cat_dog_train_path) 
labels = [0 if 'cat' in addr else 1 for addr in addrs] # 0 = Cat, 1 = Dog 

# to shuffle data 
if shuffle_data: 
    c = list(zip(addrs, labels)) 
    shuffle(c) 
    addrs, labels = zip(*c) 

Fehler:

> ValueError        Traceback (most recent call 
> last) <ipython-input-19-4408536403db> in <module>() 
>  2  c = list(zip(address, labels)) 
>  3  shuffle(c) 
> ----> 4  addrs, labels = zip(*c) 
> 
> ValueError: not enough values to unpack (expected 2, got 0) 

Referenz: http://machinelearninguru.com/deep_learning/data_preparation/hdf5/hdf5.html#list

Antwort

0

Die Website gibt Python-2-Code. Ich sehe dein Tag, verwendest du Python 3? Sie können es

2to3 -n filename.py

konvertieren mit