Reputation: 178
I've processed some data for usage with tensorflow into two python lists. Unfortunately, Tensorflow does not support Python lists as an input for fitting a model. A short and simple code snippet of what my current implementation looks like follows below:
data = loadData()
pythonListInputData = data[0]
pythonListInputLabels = data[1]
model = prepModel() #note that this uses keras
model.fit(pythonListInputData, pythonListInputLabels) #Leaving out my configuration settings here for simplicities sake
This results in an error:
ValueError: Please provide as model inputs either a single array or a list of arrays.
I get this error when pythonListInputData is either a list of lists or a list of arrays.
I've read through the Tensorflow tutorials and documentation but am struggling to find any useful info that makes this work.
Edit: Data structure is as follows:
pythonListInputData = data[0]
is a list of lists of integers e.g. [[234, 1, 4], [245, 2, 5], [123, 5, 11], ...]
I have also tried an alternative which is constructed as follows
pythonListInputData = []
for entry in data[0]:
pythonListInputData.append(array.array('I', entry))
where data[0] is the format mentioned above.
pythonListInputLabels = data[1]
is a list of integers e.g. [1, 4, 2, ...]
Upvotes: 2
Views: 1269
Reputation: 675
Sam! I'm posting here in case the answer is useful to folks in the future. We came to the answer in comments.
The issue is that the keras/ tensorflow model is expecting a numpy array
np.array(listName)
That should fix your issue! Cheers!
Upvotes: 3