Reputation: 1298
I am using the tf.keras API and I want my Model to take input with shape (None,)
, None
is batch_size.
The shape
of keras.layers.Input() doesn't include batch_size, so I think it can't be used.
Is there a way to achieve my goal? I prefer a solution without tf.placeholder
since it is deprecated
By the way, my model is a sentence embedding model, so I want the input is something like ['How are you.','Good morning.']
====================== Update:
Currently, I can create an input layer with layers.Input(dtype=tf.string,shape=1)
, but this need my input to be something like [['How are you.'],['Good morning.']]
. I want my input to have only one dimension.
Upvotes: 2
Views: 2474
Reputation: 2744
Have you tried tf.keras.layers.Input(dtype=tf.string, shape=())
?
Upvotes: 2
Reputation: 1665
If you wanted to set a specific batch size, tf.keras.Input()
does actually include a batch_size
parameter. But the batch size is presumed to be None
by default, so you shouldn't even need to change anything.
Now, it seems like what you actually want is to be able to provide samples (sentences) of variable length. Good news! The tf.keras.layers.Embedding
layer allows you to do this, although you'll have to generate an encoding for your sentences first. The Tensorflow website has a good tutorial on the process.
Upvotes: 0