tuple()函数和shape[0]的应用

batch = np.array([1,1,1,1,1])
batch = tuple(t for t in batch)#转换为元组形式
# print(batch)
inputs = {'slot_labels_ids': batch}
out_slot_labels_ids = np.array([2,2,2,2,2])
for i in range(5):
    out_slot_labels_ids = np.append(out_slot_labels_ids, inputs["slot_labels_ids"], axis=0)
out_slot_label_list = [[] for _ in range(out_slot_labels_ids.shape[0])]
a = out_slot_labels_ids.shape[0]
print(a)
print(out_slot_label_list)

输出:

30
[[], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], []]
发布了41 篇原创文章 · 获赞 44 · 访问量 7656

猜你喜欢

转载自blog.csdn.net/tailonh/article/details/105102435