Python – keras model prediction is not suitable, what does that mean?

keras model prediction is not suitable, what does that mean?… here is a solution to the problem.

keras model prediction is not suitable, what does that mean?

I tensorflow 2.0 API See the following sample code

model = Sequential()
model.add(Embedding(1000, 64, input_length=10))
# the model will take as input an integer matrix of size (batch,
# input_length).
# the largest integer (i.e. word index) in the input should be no larger
# than 999 (vocabulary size).
# now model.output_shape == (None, 10, 64), where None is the batch
# dimension.

input_array = np.random.randint(1000, size=(32, 10))

model.compile('rmsprop', 'mse')
output_array = model.predict(input_array)
assert output_array.shape == (32, 10, 64)

I’ve been using the keras API for a few days now and compiling, fitting and then predicting is my way.

What does the above example mean without fitting steps?

Solution

Represents the use of initialization parameters in models without fit(). This example is just to illustrate the return shape of the Embedding layer.

Related Problems and Solutions