初心者のpython zipの質問です。 私は今、udacity深い学習課題LSTMをやっています。 どのように動作するのか理解できないコード行があります。このコードのZIPは何ですか?
s = [''.join(x) for x in zip(s, characters(b))]
以下のコンテキストからコピーされます。
def batches2string(batches):
"""Convert a sequence of batches back into their (most likely) string
representation."""
s = [''] * batches[0].shape[0]
for b in batches:
s = [''.join(x) for x in zip(s, characters(b))]
return s
私はforループで書き直そうとしていますが、正しく動作していないようです。誰かがforループで書き直す方法を教えてもらえますか?ループtuple
と一致するで
s1 = [''] * batches[0].shape[0]
for b in batches:
for x in zip(s1, characters(b)):
print(x)
s1.append(x)
print(s1)
バッチ自体がリストであり、複数の2次元np.arrayが含まれています。 len(バッチ)= 11、バッチ[0] .shape =(64,27)としましょう。 –