0

I have a list l1 = ["Hello", "What is your name", "How ya Doing?"]
and l2 = ["Hi", "I am XYZ", "I'm fine, What about you"]
I want to train my model according to the index of their lists.

Problem: It requires np array for training. How to convert this list l1 and l2 to a np array that keras would accept

1 Answer 1

2

Numpy has a function to convert a python list to an array. All you need is

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])

returns

['Hello' 'What is your name' 'How ya Doing?'] 'I am XYZ'

which should do the job.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.