If k is an numpy array of an arbitrary shape, so k.shape = (s1, s2, s3, ..., sn)
, and I want to reshape it so that k.shape
becomes (s1, s2, ..., sn, 1)
, is this the best way to do it in one line?
k.reshape(*(list(k.shape) + [1])
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…