简体   繁体   English

keras模型预测不适合,这意味着什么?

[英]keras model predict without fit, what does it mean?

I see the following example code on tensorflow 2.0 API 我在tensorflow 2.0 API上看到以下示例代码

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 have used keras API for a few days, compile, fit and then predict is my way. 我已经使用了keras API几天了,进行编译,拟合然后预测是我的方式。

What does above example mean without fit step? 上面的示例没有适合的步骤意味着什么?

It represents the use of initialized parameters in the model without fit() . 它表示在不fit()的模型中使用初始化参数。 This example is just to illustrate the return shape of Embedding layer . 这个例子只是为了说明Embedding layer的返回形状。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM