我有一个清单l1 = ["Hello", "What is your name", "How ya Doing?"]
和l2 = ["Hi", "I am XYZ", "I'm fine, What about you"]
我想根据他们列表的索引来训练我的模型。
问题:它需要 np 数组进行训练。如何转换此列表 l1 和 l2 到 keras 接受的 np 数组
答案 0 :(得分:1)
Numpy 有一个函数可以将 python 列表转换为字符串。你只需要
import numpy as np
l1 = ["Hello", "What is your name", "How ya Doing?"]
l2 = ["Hi", "I am XYZ", "I'm fine, What about you"]
arr1 = np.array(l1)
arr2 = np.array(l2)
print(arr1,arr2[1])
返回
['Hello' 'What is your name' 'How ya Doing?'] 'I am XYZ'
哪个应该做这项工作。