其他分享
首页 > 其他分享> > 2021-01-17

2021-01-17

作者:互联网

‘numpy.ndarray’ object has no attribute ‘append’

def rank_generator(gen):
    target=[]
    inputs_=np.array([1, 2, 3,4,5,6])
    for inputs, targets in gen:
        target.append(targets)
        inputs_=np.vstack((inputs_, inputs[0]))
        #print("---Batch---")
        #print("Feature:", inputs)
        #print("Label:", targets)
        #print("")
    target=np.array(target)
    inputs_=inputs_[1:,:]
    return inputs_,target

np.vstack()

 import numpy as np
>>> a = np.array([1, 2, 3])
>>> b = np.array([5, 6, 7])
>>> np.vstack(a, b)   
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: vstack() takes exactly 1 argument (2 given)
>>> 
>>> np.vstack((a, b))
array([[1, 2, 3],
       [5, 6, 7]])

标签:inputs,01,target,17,vstack,print,2021,np,array
来源: https://blog.csdn.net/weixin_43662224/article/details/112728445