简体   繁体   English

编辑keras模型后,“无”是什么意思?

[英]What does a “None” mean after compilation of keras model?

I'm trying to implement a binary text classification model using keras layers. 我正在尝试使用keras层实现二进制文本分类模型。 After compiling a model, in a summary, I am getting None at the bottom end and I don't exactly understand what does it mean? 在编译模型之后,在摘要中,我在底端得到None并且我不完全理解它是什么意思?

here is the code which I am using. 这是我正在使用的代码。

max_words = 10000
max_len = 500
tok = Tokenizer(num_words=max_words)
tok.fit_on_texts(X_train)
sequences = tok.texts_to_sequences(X_train)
sequences_matrix = sequence.pad_sequences(sequences,maxlen=max_len)

model = Sequential()
model.add(Embedding(max_words, 50, input_length=max_len))
model.add(LSTM(64))
model.add(Dense(256,name='FC1',activation='relu'))
model.add(Dropout(0.5))
model.add(Dense(1, activation='sigmoid'))
model.compile(optimizer='adam', loss='binary_crossentropy', metrics= 
             ['acc'])
print(model.summary())

This is the model summary and at the bottom end It is showing None . 这是模型摘要,在底部显示

_________________________________________________________________
Layer (type)                 Output Shape              Param #   
=================================================================
embedding_1 (Embedding)      (None, 500, 50)           500000    
_________________________________________________________________
lstm_1 (LSTM)                (None, 64)                29440     
_________________________________________________________________
FC1 (Dense)                  (None, 256)               16640     
_________________________________________________________________
dropout_1 (Dropout)          (None, 256)               0         
_________________________________________________________________
dense_1 (Dense)              (None, 1)                 257       
=================================================================
Total params: 546,337
Trainable params: 546,337
Non-trainable params: 0
_________________________________________________________________
None

model.summary() returns nothing ( None ), and you are printing the return value of it. model.summary()返回任何内容( None ),而是打印它的返回值。 model.summary() already does the printing internally, there is no need to get confused with printing it manually, so just do: model.summary()已经在内部进行打印,没有必要混淆手动打印,所以只需:

model.summary()

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

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