という2つの次元を持つリストがあります。 a[0]
は1000画像のタプルで、a[1]
はラベルのタプルです。これは、対応するペアを結合します2番目の次元の項目に基づいて2つのタプルのリストを分割します。
for image, label in zip(*a):
:私は、次のコードを実行しようとしています:
from collections import defaultdict
images = defaultdict(list)
for image, label in a:
images[label].append(image)
for k,v in images.iteritems():
print('Label {} has {} images'.format(k, len(v)))
をしかし、私は次のエラーを取得しています:
for image, label in a:
ValueError: too many values to unpack
イメージにはzip': '、ラベルにはzip(* a):...というラベルを使用できます。 – falsetru