我有一个列表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数组
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'
应该完成这项工作。