Reputation: 1439
I have a generator, which yield
s the following:
yield {'ingredients': ingredients, 'documents': documents}, labels
The yield'd iterator has the following shape:
ingredients.shape (10, 46) documents.shape (10, 46) labels.shape (10,)
Once this iterator is fed through do my model, I get the following:
ValueError: Error when checking input: expected ingredients to have shape (1,) but got array with shape (46,)
Here is the model code which produces the above error:
# Both inputs are 1-dimensional
ingredients = Input(
name='ingredients',
shape=[1]
)
# ingredients.shape (?, 1)
documents = Input(
name='documents',
shape=[1]
)
# documents.shape (?, 1)
logger.info('ingredients %s documents shape %s', ingredients.shape, documents.shape)
ingredients_embedding = Embedding(name='ingredients_embedding',
input_dim=training_size,
output_dim=embedded_document_size)(ingredients)
# Embedding the document (shape will be (None, 1, embedding_size))
document_embedding = Embedding(name='documents_embedding',
input_dim=training_size,
output_dim=embedded_document_size)(documents)
Upvotes: 0
Views: 30
Reputation: 4289
The input_shape
mentioned in the ingredients
and documents
Input layer is ( 1 ). But, the shape of ingredients is ( 10 , 46 ) and that of the documents is ( 10 , 46 ). Here 10 is the number of samples.
You are initializing the model to have an input of shape ( None , 1 ). It should be ( None , 46 ). Hence, you can make these changes.
ingredients = Input( name='ingredients', shape=( 46 , ) )
documents = Input( name='documents', shape=( 46 , )
This should fix the error. Actually speaking the input has 46 dimensions or 46 features.
Upvotes: 1