【发布时间】:2017-01-23 09:23:03
【问题描述】:
我在numpy中有如下函数:
A = np.array([[1, 2, 3],
[4, 5, 6],
[7, 8, 9],
[10, 11, 12]])
def insert_row_averages(A, n=2):
slice2 = A[n::n]
v = (A[n-1::n][:slice2.shape[0]] + slice2)/2.0
np.insert(A.astype(float),n*np.arange(1,v.shape[0]+1),v,axis=0)
它基本上取上下行的平均值,并每隔 n 间隔将其插入两者之间。
知道如何在 Tensorflow 中完成这项工作吗?具体来说,我可以用什么来代替 np.insert,因为似乎没有等效的功能。
【问题讨论】:
标签: arrays numpy insert tensorflow