1
這是一個初學者的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循環中重寫它?
s1 = [''] * batches[0].shape[0]
for b in batches:
for x in zip(s1, characters(b)):
print(x)
s1.append(x)
print(s1)
批本身是一個列表,包含幾個2-dim np.array。比方說len(批次)= 11,批次[0] .shape =(64,27) –