1

When I have tried to run this code:

model = Sequential()
model.add(Embedding(len(set(text_words)), 100,input_length=8555))
model.compile('rmsprop', 'mse')
output_array = model.predict(b)

I got this error:

ValueError: Error when checking input: expected embedding_1_input to have shape (8555,) but got array with shape (1,)

What is going wrong in this section?

I am using NumPy array data. Variable b is the NumPy array data in my code.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
michel
  • 13
  • 3
  • Possible duplicate of [List of lists into numpy array](https://stackoverflow.com/questions/10346336/list-of-lists-into-numpy-array) – Thomas Dussaut Apr 03 '19 at 09:38
  • Numpy has a `flatten` method for this https://docs.scipy.org/doc/numpy/reference/generated/numpy.ndarray.flatten.html – alec_djinn Apr 03 '19 at 11:02

1 Answers1

1

To convert a list of lists to a numpy array then print its shape and size:

import numpy as np 

numpy_array = np.array(list_of_lists)
print("shape:", numpy_array.shape," size", numpy_array.size)
SuperKogito
  • 2,998
  • 3
  • 16
  • 37