Closed MattHuntebrinker closed 5 years ago
I need more details, please run model.tf_model.summary()
to print out model details, and which function you use to predict?
here's the code used to train and predict, since i'm not exactly sure what you're looking for.
from kashgari.corpus import CONLL2003ENCorpus
import kashgari
from kashgari.tasks.labeling import BiLSTM_Model
train_x, train_y = CONLL2003ENCorpus.load_data('train')
valid_x, valid_y = CONLL2003ENCorpus.load_data('valid')
test_x, test_y = CONLL2003ENCorpus.load_data('test')
bert_embed = BERTEmbedding('bert',
task=kashgari.LABELING,
sequence_length=100)
model = BiLSTM_Model(bert_embed)
model.fit(train_x, train_y, valid_x, valid_y)
model.evaluate(test_x, test_y)
model.save('saved_ner_model')
x = ['A', 'purple ', 'pig ', 'and:', 'a', 'green', 'donkey', 'flew', 'a', 'kite', 'in', 'the', 'middle', 'of', 'the', 'night', 'and', 'ended', 'up', 'sunburnt']
loaded_model = kashgari.utils.load_model('saved_ner_model')
loaded_model.predict([x])
I need the result of this code
import logging
logging.basicConfig(level='DEBUG')
print(kashgari.__version__)
loaded_model.tf_model.summary()
loaded_model.predict([x], debug_info=True)
0.5.0
x[0]: ['Supplement', 'Facts', 'Serving', 'Size:', '1tsp', '5mL', 'Servings', 'Per', 'Container:', '19', 'Calories', '11', 'Cal', 'SUGARS†', '3', 'g', 'Total', 'Carbohydrate**', '3', 'g', '1%', 'SENNA', 'POD', 'CONCENTRATE†', '167', 'mg', 'PURIFIED', 'WATER,', 'SUCROSE,', 'MALTODEXTRIN,', 'GLYCERIN,', 'SODIUM', 'BENZOATE', '(PRESERVATIVE),', 'ARTIFICIAL', 'FLAVOR,', 'METHYLPARABEN', '(PRESERVATIVE),', 'CITRIC', 'ACID,', 'PROPYLPARABEN', '(PRESERVATIVE).', 'percent', 'daily', 'value', 'based', 'on', '2000', 'calorie', 'diet']
y[0]: ['O', 'O', 'O', 'O', 'B-SS', 'I-SS', 'O', 'O', 'O', 'B-SC', 'B-N', 'B-A', 'I-A', 'B-N', 'B-A', 'I-A', 'B-N', 'I-N', 'B-A', 'I-A', 'B-DV', 'B-I', 'I-I', 'I-I', 'B-A', 'I-A', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O']
DEBUG:root:loaded 3194 samples from ./data/valid.txt. Sample:
x[0]: ['Supplement', 'Facts', 'Serving', 'Size:', '1', 'SCOOP', '8.5g', 'Servings', 'Per', 'Container:', '10', 'Calories', '15Cal', 'Sodium', '510mg', '22%', 'GOBHB', 'BETA', 'HYDROXYBUTYRATE**', '6g', 'Potassium', '200mg', '4%', 'Calcium', '260mg', '20%', 'Magnesium', '75mg', '18%', 'SODIUM', 'BHB,', 'CALCIUM', 'BHB,', 'MAGNESIUM', 'BHB,', 'POTASSIUM', 'CITRATE,', 'CITRIC', 'ACID,', 'MALIC', 'ACID,', 'NATURAL', 'FLAVORS,', 'SILICON', 'DIOXIDE,', 'STEVIA', 'EXTRACT,', 'BETA', 'CAROTENE', '(NO', 'COLORS', 'FROM', 'ARTIFICIAL', 'SOURCES)']
y[0]: ['O', 'O', 'O', 'O', 'B-SS', 'I-SS', 'I-SS', 'O', 'O', 'O', 'B-SC', 'B-N', 'B-A', 'B-N', 'B-A', 'B-DV', 'B-I', 'I-I', 'I-I', 'B-A', 'B-N', 'B-A', 'B-DV', 'B-N', 'B-A', 'B-DV', 'B-N', 'B-A', 'B-DV', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O']
DEBUG:root:loaded 3074 samples from ./data/test.txt. Sample:
x[0]: ['Supplement', 'Facts', 'Serving', 'Size:', 'SOFTGEL', '1Gel', 'VITAMIN', 'D3', '(AS', 'CHOLECALCIFEROL)', '(1000', 'IU)', '25', 'mcg', '125%', 'SOYBEAN', 'OIL,', 'GELATIN,', 'GLYCERIN,', 'WATER.', 'percent', 'daily', 'value', 'based', 'on', '2000', 'calorie', 'diet']
y[0]: ['O', 'O', 'O', 'O', 'B-SS', 'I-SS', 'B-N', 'I-N', 'I-N', 'I-N', 'I-N', 'I-N', 'B-A', 'I-A', 'B-DV', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O']
WARNING:root:Sequence length will auto set at 95% of sequence length
DEBUG:root:need to build after build_word2idx
__________________________________________________________________________________________________
Layer (type) Output Shape Param # Connected to
==================================================================================================
Input-Token (InputLayer) (None, 10) 0
__________________________________________________________________________________________________
Input-Segment (InputLayer) (None, 10) 0
__________________________________________________________________________________________________
Embedding-Token (TokenEmbedding [(None, 10, 1024), ( 31254528 Input-Token[0][0]
__________________________________________________________________________________________________
Embedding-Segment (Embedding) (None, 10, 1024) 2048 Input-Segment[0][0]
__________________________________________________________________________________________________
Embedding-Token-Segment (Add) (None, 10, 1024) 0 Embedding-Token[0][0]
Embedding-Segment[0][0]
__________________________________________________________________________________________________
Embedding-Position (PositionEmb (None, 10, 1024) 10240 Embedding-Token-Segment[0][0]
__________________________________________________________________________________________________
Embedding-Dropout (Dropout) (None, 10, 1024) 0 Embedding-Position[0][0]
__________________________________________________________________________________________________
Embedding-Norm (LayerNormalizat (None, 10, 1024) 2048 Embedding-Dropout[0][0]
__________________________________________________________________________________________________
Encoder-1-MultiHeadSelfAttentio (None, 10, 1024) 4198400 Embedding-Norm[0][0]
__________________________________________________________________________________________________
Encoder-1-MultiHeadSelfAttentio (None, 10, 1024) 0 Encoder-1-MultiHeadSelfAttention[
__________________________________________________________________________________________________
Encoder-1-MultiHeadSelfAttentio (None, 10, 1024) 0 Embedding-Norm[0][0]
Encoder-1-MultiHeadSelfAttention-
__________________________________________________________________________________________________
Encoder-1-MultiHeadSelfAttentio (None, 10, 1024) 2048 Encoder-1-MultiHeadSelfAttention-
__________________________________________________________________________________________________
Encoder-1-FeedForward (FeedForw (None, 10, 1024) 8393728 Encoder-1-MultiHeadSelfAttention-
__________________________________________________________________________________________________
Encoder-1-FeedForward-Dropout ( (None, 10, 1024) 0 Encoder-1-FeedForward[0][0]
__________________________________________________________________________________________________
Encoder-1-FeedForward-Add (Add) (None, 10, 1024) 0 Encoder-1-MultiHeadSelfAttention-
Encoder-1-FeedForward-Dropout[0][
__________________________________________________________________________________________________
Encoder-1-FeedForward-Norm (Lay (None, 10, 1024) 2048 Encoder-1-FeedForward-Add[0][0]
__________________________________________________________________________________________________
Encoder-2-MultiHeadSelfAttentio (None, 10, 1024) 4198400 Encoder-1-FeedForward-Norm[0][0]
__________________________________________________________________________________________________
Encoder-2-MultiHeadSelfAttentio (None, 10, 1024) 0 Encoder-2-MultiHeadSelfAttention[
__________________________________________________________________________________________________
Encoder-2-MultiHeadSelfAttentio (None, 10, 1024) 0 Encoder-1-FeedForward-Norm[0][0]
Encoder-2-MultiHeadSelfAttention-
__________________________________________________________________________________________________
Encoder-2-MultiHeadSelfAttentio (None, 10, 1024) 2048 Encoder-2-MultiHeadSelfAttention-
__________________________________________________________________________________________________
Encoder-2-FeedForward (FeedForw (None, 10, 1024) 8393728 Encoder-2-MultiHeadSelfAttention-
__________________________________________________________________________________________________
Encoder-2-FeedForward-Dropout ( (None, 10, 1024) 0 Encoder-2-FeedForward[0][0]
__________________________________________________________________________________________________
Encoder-2-FeedForward-Add (Add) (None, 10, 1024) 0 Encoder-2-MultiHeadSelfAttention-
Encoder-2-FeedForward-Dropout[0][
__________________________________________________________________________________________________
Encoder-2-FeedForward-Norm (Lay (None, 10, 1024) 2048 Encoder-2-FeedForward-Add[0][0]
__________________________________________________________________________________________________
Encoder-3-MultiHeadSelfAttentio (None, 10, 1024) 4198400 Encoder-2-FeedForward-Norm[0][0]
__________________________________________________________________________________________________
Encoder-3-MultiHeadSelfAttentio (None, 10, 1024) 0 Encoder-3-MultiHeadSelfAttention[
__________________________________________________________________________________________________
Encoder-3-MultiHeadSelfAttentio (None, 10, 1024) 0 Encoder-2-FeedForward-Norm[0][0]
Encoder-3-MultiHeadSelfAttention-
__________________________________________________________________________________________________
Encoder-3-MultiHeadSelfAttentio (None, 10, 1024) 2048 Encoder-3-MultiHeadSelfAttention-
__________________________________________________________________________________________________
Encoder-3-FeedForward (FeedForw (None, 10, 1024) 8393728 Encoder-3-MultiHeadSelfAttention-
__________________________________________________________________________________________________
Encoder-3-FeedForward-Dropout ( (None, 10, 1024) 0 Encoder-3-FeedForward[0][0]
__________________________________________________________________________________________________
Encoder-3-FeedForward-Add (Add) (None, 10, 1024) 0 Encoder-3-MultiHeadSelfAttention-
Encoder-3-FeedForward-Dropout[0][
__________________________________________________________________________________________________
Encoder-3-FeedForward-Norm (Lay (None, 10, 1024) 2048 Encoder-3-FeedForward-Add[0][0]
__________________________________________________________________________________________________
Encoder-4-MultiHeadSelfAttentio (None, 10, 1024) 4198400 Encoder-3-FeedForward-Norm[0][0]
__________________________________________________________________________________________________
Encoder-4-MultiHeadSelfAttentio (None, 10, 1024) 0 Encoder-4-MultiHeadSelfAttention[
__________________________________________________________________________________________________
Encoder-4-MultiHeadSelfAttentio (None, 10, 1024) 0 Encoder-3-FeedForward-Norm[0][0]
Encoder-4-MultiHeadSelfAttention-
__________________________________________________________________________________________________
Encoder-4-MultiHeadSelfAttentio (None, 10, 1024) 2048 Encoder-4-MultiHeadSelfAttention-
__________________________________________________________________________________________________
Encoder-4-FeedForward (FeedForw (None, 10, 1024) 8393728 Encoder-4-MultiHeadSelfAttention-
__________________________________________________________________________________________________
Encoder-4-FeedForward-Dropout ( (None, 10, 1024) 0 Encoder-4-FeedForward[0][0]
__________________________________________________________________________________________________
Encoder-4-FeedForward-Add (Add) (None, 10, 1024) 0 Encoder-4-MultiHeadSelfAttention-
Encoder-4-FeedForward-Dropout[0][
__________________________________________________________________________________________________
Encoder-4-FeedForward-Norm (Lay (None, 10, 1024) 2048 Encoder-4-FeedForward-Add[0][0]
__________________________________________________________________________________________________
Encoder-5-MultiHeadSelfAttentio (None, 10, 1024) 4198400 Encoder-4-FeedForward-Norm[0][0]
__________________________________________________________________________________________________
Encoder-5-MultiHeadSelfAttentio (None, 10, 1024) 0 Encoder-5-MultiHeadSelfAttention[
__________________________________________________________________________________________________
Encoder-5-MultiHeadSelfAttentio (None, 10, 1024) 0 Encoder-4-FeedForward-Norm[0][0]
Encoder-5-MultiHeadSelfAttention-
__________________________________________________________________________________________________
Encoder-5-MultiHeadSelfAttentio (None, 10, 1024) 2048 Encoder-5-MultiHeadSelfAttention-
__________________________________________________________________________________________________
Encoder-5-FeedForward (FeedForw (None, 10, 1024) 8393728 Encoder-5-MultiHeadSelfAttention-
__________________________________________________________________________________________________
Encoder-5-FeedForward-Dropout ( (None, 10, 1024) 0 Encoder-5-FeedForward[0][0]
__________________________________________________________________________________________________
Encoder-5-FeedForward-Add (Add) (None, 10, 1024) 0 Encoder-5-MultiHeadSelfAttention-
Encoder-5-FeedForward-Dropout[0][
__________________________________________________________________________________________________
Encoder-5-FeedForward-Norm (Lay (None, 10, 1024) 2048 Encoder-5-FeedForward-Add[0][0]
__________________________________________________________________________________________________
Encoder-6-MultiHeadSelfAttentio (None, 10, 1024) 4198400 Encoder-5-FeedForward-Norm[0][0]
__________________________________________________________________________________________________
Encoder-6-MultiHeadSelfAttentio (None, 10, 1024) 0 Encoder-6-MultiHeadSelfAttention[
__________________________________________________________________________________________________
Encoder-6-MultiHeadSelfAttentio (None, 10, 1024) 0 Encoder-5-FeedForward-Norm[0][0]
Encoder-6-MultiHeadSelfAttention-
__________________________________________________________________________________________________
Encoder-6-MultiHeadSelfAttentio (None, 10, 1024) 2048 Encoder-6-MultiHeadSelfAttention-
__________________________________________________________________________________________________
Encoder-6-FeedForward (FeedForw (None, 10, 1024) 8393728 Encoder-6-MultiHeadSelfAttention-
__________________________________________________________________________________________________
Encoder-6-FeedForward-Dropout ( (None, 10, 1024) 0 Encoder-6-FeedForward[0][0]
__________________________________________________________________________________________________
Encoder-6-FeedForward-Add (Add) (None, 10, 1024) 0 Encoder-6-MultiHeadSelfAttention-
Encoder-6-FeedForward-Dropout[0][
__________________________________________________________________________________________________
Encoder-6-FeedForward-Norm (Lay (None, 10, 1024) 2048 Encoder-6-FeedForward-Add[0][0]
__________________________________________________________________________________________________
Encoder-7-MultiHeadSelfAttentio (None, 10, 1024) 4198400 Encoder-6-FeedForward-Norm[0][0]
__________________________________________________________________________________________________
Encoder-7-MultiHeadSelfAttentio (None, 10, 1024) 0 Encoder-7-MultiHeadSelfAttention[
__________________________________________________________________________________________________
Encoder-7-MultiHeadSelfAttentio (None, 10, 1024) 0 Encoder-6-FeedForward-Norm[0][0]
Encoder-7-MultiHeadSelfAttention-
__________________________________________________________________________________________________
Encoder-7-MultiHeadSelfAttentio (None, 10, 1024) 2048 Encoder-7-MultiHeadSelfAttention-
__________________________________________________________________________________________________
Encoder-7-FeedForward (FeedForw (None, 10, 1024) 8393728 Encoder-7-MultiHeadSelfAttention-
__________________________________________________________________________________________________
Encoder-7-FeedForward-Dropout ( (None, 10, 1024) 0 Encoder-7-FeedForward[0][0]
__________________________________________________________________________________________________
Encoder-7-FeedForward-Add (Add) (None, 10, 1024) 0 Encoder-7-MultiHeadSelfAttention-
Encoder-7-FeedForward-Dropout[0][
__________________________________________________________________________________________________
Encoder-7-FeedForward-Norm (Lay (None, 10, 1024) 2048 Encoder-7-FeedForward-Add[0][0]
__________________________________________________________________________________________________
Encoder-8-MultiHeadSelfAttentio (None, 10, 1024) 4198400 Encoder-7-FeedForward-Norm[0][0]
__________________________________________________________________________________________________
Encoder-8-MultiHeadSelfAttentio (None, 10, 1024) 0 Encoder-8-MultiHeadSelfAttention[
__________________________________________________________________________________________________
Encoder-8-MultiHeadSelfAttentio (None, 10, 1024) 0 Encoder-7-FeedForward-Norm[0][0]
Encoder-8-MultiHeadSelfAttention-
__________________________________________________________________________________________________
Encoder-8-MultiHeadSelfAttentio (None, 10, 1024) 2048 Encoder-8-MultiHeadSelfAttention-
__________________________________________________________________________________________________
Encoder-8-FeedForward (FeedForw (None, 10, 1024) 8393728 Encoder-8-MultiHeadSelfAttention-
__________________________________________________________________________________________________
Encoder-8-FeedForward-Dropout ( (None, 10, 1024) 0 Encoder-8-FeedForward[0][0]
__________________________________________________________________________________________________
Encoder-8-FeedForward-Add (Add) (None, 10, 1024) 0 Encoder-8-MultiHeadSelfAttention-
Encoder-8-FeedForward-Dropout[0][
__________________________________________________________________________________________________
Encoder-8-FeedForward-Norm (Lay (None, 10, 1024) 2048 Encoder-8-FeedForward-Add[0][0]
__________________________________________________________________________________________________
Encoder-9-MultiHeadSelfAttentio (None, 10, 1024) 4198400 Encoder-8-FeedForward-Norm[0][0]
__________________________________________________________________________________________________
Encoder-9-MultiHeadSelfAttentio (None, 10, 1024) 0 Encoder-9-MultiHeadSelfAttention[
__________________________________________________________________________________________________
Encoder-9-MultiHeadSelfAttentio (None, 10, 1024) 0 Encoder-8-FeedForward-Norm[0][0]
Encoder-9-MultiHeadSelfAttention-
__________________________________________________________________________________________________
Encoder-9-MultiHeadSelfAttentio (None, 10, 1024) 2048 Encoder-9-MultiHeadSelfAttention-
__________________________________________________________________________________________________
Encoder-9-FeedForward (FeedForw (None, 10, 1024) 8393728 Encoder-9-MultiHeadSelfAttention-
__________________________________________________________________________________________________
Encoder-9-FeedForward-Dropout ( (None, 10, 1024) 0 Encoder-9-FeedForward[0][0]
__________________________________________________________________________________________________
Encoder-9-FeedForward-Add (Add) (None, 10, 1024) 0 Encoder-9-MultiHeadSelfAttention-
Encoder-9-FeedForward-Dropout[0][
__________________________________________________________________________________________________
Encoder-9-FeedForward-Norm (Lay (None, 10, 1024) 2048 Encoder-9-FeedForward-Add[0][0]
__________________________________________________________________________________________________
Encoder-10-MultiHeadSelfAttenti (None, 10, 1024) 4198400 Encoder-9-FeedForward-Norm[0][0]
__________________________________________________________________________________________________
Encoder-10-MultiHeadSelfAttenti (None, 10, 1024) 0 Encoder-10-MultiHeadSelfAttention
__________________________________________________________________________________________________
Encoder-10-MultiHeadSelfAttenti (None, 10, 1024) 0 Encoder-9-FeedForward-Norm[0][0]
Encoder-10-MultiHeadSelfAttention
__________________________________________________________________________________________________
Encoder-10-MultiHeadSelfAttenti (None, 10, 1024) 2048 Encoder-10-MultiHeadSelfAttention
__________________________________________________________________________________________________
Encoder-10-FeedForward (FeedFor (None, 10, 1024) 8393728 Encoder-10-MultiHeadSelfAttention
__________________________________________________________________________________________________
Encoder-10-FeedForward-Dropout (None, 10, 1024) 0 Encoder-10-FeedForward[0][0]
__________________________________________________________________________________________________
Encoder-10-FeedForward-Add (Add (None, 10, 1024) 0 Encoder-10-MultiHeadSelfAttention
Encoder-10-FeedForward-Dropout[0]
__________________________________________________________________________________________________
Encoder-10-FeedForward-Norm (La (None, 10, 1024) 2048 Encoder-10-FeedForward-Add[0][0]
__________________________________________________________________________________________________
Encoder-11-MultiHeadSelfAttenti (None, 10, 1024) 4198400 Encoder-10-FeedForward-Norm[0][0]
__________________________________________________________________________________________________
Encoder-11-MultiHeadSelfAttenti (None, 10, 1024) 0 Encoder-11-MultiHeadSelfAttention
__________________________________________________________________________________________________
Encoder-11-MultiHeadSelfAttenti (None, 10, 1024) 0 Encoder-10-FeedForward-Norm[0][0]
Encoder-11-MultiHeadSelfAttention
__________________________________________________________________________________________________
Encoder-11-MultiHeadSelfAttenti (None, 10, 1024) 2048 Encoder-11-MultiHeadSelfAttention
__________________________________________________________________________________________________
Encoder-11-FeedForward (FeedFor (None, 10, 1024) 8393728 Encoder-11-MultiHeadSelfAttention
__________________________________________________________________________________________________
Encoder-11-FeedForward-Dropout (None, 10, 1024) 0 Encoder-11-FeedForward[0][0]
__________________________________________________________________________________________________
Encoder-11-FeedForward-Add (Add (None, 10, 1024) 0 Encoder-11-MultiHeadSelfAttention
Encoder-11-FeedForward-Dropout[0]
__________________________________________________________________________________________________
Encoder-11-FeedForward-Norm (La (None, 10, 1024) 2048 Encoder-11-FeedForward-Add[0][0]
__________________________________________________________________________________________________
Encoder-12-MultiHeadSelfAttenti (None, 10, 1024) 4198400 Encoder-11-FeedForward-Norm[0][0]
__________________________________________________________________________________________________
Encoder-12-MultiHeadSelfAttenti (None, 10, 1024) 0 Encoder-12-MultiHeadSelfAttention
__________________________________________________________________________________________________
Encoder-12-MultiHeadSelfAttenti (None, 10, 1024) 0 Encoder-11-FeedForward-Norm[0][0]
Encoder-12-MultiHeadSelfAttention
__________________________________________________________________________________________________
Encoder-12-MultiHeadSelfAttenti (None, 10, 1024) 2048 Encoder-12-MultiHeadSelfAttention
__________________________________________________________________________________________________
Encoder-12-FeedForward (FeedFor (None, 10, 1024) 8393728 Encoder-12-MultiHeadSelfAttention
__________________________________________________________________________________________________
Encoder-12-FeedForward-Dropout (None, 10, 1024) 0 Encoder-12-FeedForward[0][0]
__________________________________________________________________________________________________
Encoder-12-FeedForward-Add (Add (None, 10, 1024) 0 Encoder-12-MultiHeadSelfAttention
Encoder-12-FeedForward-Dropout[0]
__________________________________________________________________________________________________
Encoder-12-FeedForward-Norm (La (None, 10, 1024) 2048 Encoder-12-FeedForward-Add[0][0]
__________________________________________________________________________________________________
Encoder-13-MultiHeadSelfAttenti (None, 10, 1024) 4198400 Encoder-12-FeedForward-Norm[0][0]
__________________________________________________________________________________________________
Encoder-13-MultiHeadSelfAttenti (None, 10, 1024) 0 Encoder-13-MultiHeadSelfAttention
__________________________________________________________________________________________________
Encoder-13-MultiHeadSelfAttenti (None, 10, 1024) 0 Encoder-12-FeedForward-Norm[0][0]
Encoder-13-MultiHeadSelfAttention
__________________________________________________________________________________________________
Encoder-13-MultiHeadSelfAttenti (None, 10, 1024) 2048 Encoder-13-MultiHeadSelfAttention
__________________________________________________________________________________________________
Encoder-13-FeedForward (FeedFor (None, 10, 1024) 8393728 Encoder-13-MultiHeadSelfAttention
__________________________________________________________________________________________________
Encoder-13-FeedForward-Dropout (None, 10, 1024) 0 Encoder-13-FeedForward[0][0]
__________________________________________________________________________________________________
Encoder-13-FeedForward-Add (Add (None, 10, 1024) 0 Encoder-13-MultiHeadSelfAttention
Encoder-13-FeedForward-Dropout[0]
__________________________________________________________________________________________________
Encoder-13-FeedForward-Norm (La (None, 10, 1024) 2048 Encoder-13-FeedForward-Add[0][0]
__________________________________________________________________________________________________
Encoder-14-MultiHeadSelfAttenti (None, 10, 1024) 4198400 Encoder-13-FeedForward-Norm[0][0]
__________________________________________________________________________________________________
Encoder-14-MultiHeadSelfAttenti (None, 10, 1024) 0 Encoder-14-MultiHeadSelfAttention
__________________________________________________________________________________________________
Encoder-14-MultiHeadSelfAttenti (None, 10, 1024) 0 Encoder-13-FeedForward-Norm[0][0]
Encoder-14-MultiHeadSelfAttention
__________________________________________________________________________________________________
Encoder-14-MultiHeadSelfAttenti (None, 10, 1024) 2048 Encoder-14-MultiHeadSelfAttention
__________________________________________________________________________________________________
Encoder-14-FeedForward (FeedFor (None, 10, 1024) 8393728 Encoder-14-MultiHeadSelfAttention
__________________________________________________________________________________________________
Encoder-14-FeedForward-Dropout (None, 10, 1024) 0 Encoder-14-FeedForward[0][0]
__________________________________________________________________________________________________
Encoder-14-FeedForward-Add (Add (None, 10, 1024) 0 Encoder-14-MultiHeadSelfAttention
Encoder-14-FeedForward-Dropout[0]
__________________________________________________________________________________________________
Encoder-14-FeedForward-Norm (La (None, 10, 1024) 2048 Encoder-14-FeedForward-Add[0][0]
__________________________________________________________________________________________________
Encoder-15-MultiHeadSelfAttenti (None, 10, 1024) 4198400 Encoder-14-FeedForward-Norm[0][0]
__________________________________________________________________________________________________
Encoder-15-MultiHeadSelfAttenti (None, 10, 1024) 0 Encoder-15-MultiHeadSelfAttention
__________________________________________________________________________________________________
Encoder-15-MultiHeadSelfAttenti (None, 10, 1024) 0 Encoder-14-FeedForward-Norm[0][0]
Encoder-15-MultiHeadSelfAttention
__________________________________________________________________________________________________
Encoder-15-MultiHeadSelfAttenti (None, 10, 1024) 2048 Encoder-15-MultiHeadSelfAttention
__________________________________________________________________________________________________
Encoder-15-FeedForward (FeedFor (None, 10, 1024) 8393728 Encoder-15-MultiHeadSelfAttention
__________________________________________________________________________________________________
Encoder-15-FeedForward-Dropout (None, 10, 1024) 0 Encoder-15-FeedForward[0][0]
__________________________________________________________________________________________________
Encoder-15-FeedForward-Add (Add (None, 10, 1024) 0 Encoder-15-MultiHeadSelfAttention
Encoder-15-FeedForward-Dropout[0]
__________________________________________________________________________________________________
Encoder-15-FeedForward-Norm (La (None, 10, 1024) 2048 Encoder-15-FeedForward-Add[0][0]
__________________________________________________________________________________________________
Encoder-16-MultiHeadSelfAttenti (None, 10, 1024) 4198400 Encoder-15-FeedForward-Norm[0][0]
__________________________________________________________________________________________________
Encoder-16-MultiHeadSelfAttenti (None, 10, 1024) 0 Encoder-16-MultiHeadSelfAttention
__________________________________________________________________________________________________
Encoder-16-MultiHeadSelfAttenti (None, 10, 1024) 0 Encoder-15-FeedForward-Norm[0][0]
Encoder-16-MultiHeadSelfAttention
__________________________________________________________________________________________________
Encoder-16-MultiHeadSelfAttenti (None, 10, 1024) 2048 Encoder-16-MultiHeadSelfAttention
__________________________________________________________________________________________________
Encoder-16-FeedForward (FeedFor (None, 10, 1024) 8393728 Encoder-16-MultiHeadSelfAttention
__________________________________________________________________________________________________
Encoder-16-FeedForward-Dropout (None, 10, 1024) 0 Encoder-16-FeedForward[0][0]
__________________________________________________________________________________________________
Encoder-16-FeedForward-Add (Add (None, 10, 1024) 0 Encoder-16-MultiHeadSelfAttention
Encoder-16-FeedForward-Dropout[0]
__________________________________________________________________________________________________
Encoder-16-FeedForward-Norm (La (None, 10, 1024) 2048 Encoder-16-FeedForward-Add[0][0]
__________________________________________________________________________________________________
Encoder-17-MultiHeadSelfAttenti (None, 10, 1024) 4198400 Encoder-16-FeedForward-Norm[0][0]
__________________________________________________________________________________________________
Encoder-17-MultiHeadSelfAttenti (None, 10, 1024) 0 Encoder-17-MultiHeadSelfAttention
__________________________________________________________________________________________________
Encoder-17-MultiHeadSelfAttenti (None, 10, 1024) 0 Encoder-16-FeedForward-Norm[0][0]
Encoder-17-MultiHeadSelfAttention
__________________________________________________________________________________________________
Encoder-17-MultiHeadSelfAttenti (None, 10, 1024) 2048 Encoder-17-MultiHeadSelfAttention
__________________________________________________________________________________________________
Encoder-17-FeedForward (FeedFor (None, 10, 1024) 8393728 Encoder-17-MultiHeadSelfAttention
__________________________________________________________________________________________________
Encoder-17-FeedForward-Dropout (None, 10, 1024) 0 Encoder-17-FeedForward[0][0]
__________________________________________________________________________________________________
Encoder-17-FeedForward-Add (Add (None, 10, 1024) 0 Encoder-17-MultiHeadSelfAttention
Encoder-17-FeedForward-Dropout[0]
__________________________________________________________________________________________________
Encoder-17-FeedForward-Norm (La (None, 10, 1024) 2048 Encoder-17-FeedForward-Add[0][0]
__________________________________________________________________________________________________
Encoder-18-MultiHeadSelfAttenti (None, 10, 1024) 4198400 Encoder-17-FeedForward-Norm[0][0]
__________________________________________________________________________________________________
Encoder-18-MultiHeadSelfAttenti (None, 10, 1024) 0 Encoder-18-MultiHeadSelfAttention
__________________________________________________________________________________________________
Encoder-18-MultiHeadSelfAttenti (None, 10, 1024) 0 Encoder-17-FeedForward-Norm[0][0]
Encoder-18-MultiHeadSelfAttention
__________________________________________________________________________________________________
Encoder-18-MultiHeadSelfAttenti (None, 10, 1024) 2048 Encoder-18-MultiHeadSelfAttention
__________________________________________________________________________________________________
Encoder-18-FeedForward (FeedFor (None, 10, 1024) 8393728 Encoder-18-MultiHeadSelfAttention
__________________________________________________________________________________________________
Encoder-18-FeedForward-Dropout (None, 10, 1024) 0 Encoder-18-FeedForward[0][0]
__________________________________________________________________________________________________
Encoder-18-FeedForward-Add (Add (None, 10, 1024) 0 Encoder-18-MultiHeadSelfAttention
Encoder-18-FeedForward-Dropout[0]
__________________________________________________________________________________________________
Encoder-18-FeedForward-Norm (La (None, 10, 1024) 2048 Encoder-18-FeedForward-Add[0][0]
__________________________________________________________________________________________________
Encoder-19-MultiHeadSelfAttenti (None, 10, 1024) 4198400 Encoder-18-FeedForward-Norm[0][0]
__________________________________________________________________________________________________
Encoder-19-MultiHeadSelfAttenti (None, 10, 1024) 0 Encoder-19-MultiHeadSelfAttention
__________________________________________________________________________________________________
Encoder-19-MultiHeadSelfAttenti (None, 10, 1024) 0 Encoder-18-FeedForward-Norm[0][0]
Encoder-19-MultiHeadSelfAttention
__________________________________________________________________________________________________
Encoder-19-MultiHeadSelfAttenti (None, 10, 1024) 2048 Encoder-19-MultiHeadSelfAttention
__________________________________________________________________________________________________
Encoder-19-FeedForward (FeedFor (None, 10, 1024) 8393728 Encoder-19-MultiHeadSelfAttention
__________________________________________________________________________________________________
Encoder-19-FeedForward-Dropout (None, 10, 1024) 0 Encoder-19-FeedForward[0][0]
__________________________________________________________________________________________________
Encoder-19-FeedForward-Add (Add (None, 10, 1024) 0 Encoder-19-MultiHeadSelfAttention
Encoder-19-FeedForward-Dropout[0]
__________________________________________________________________________________________________
Encoder-19-FeedForward-Norm (La (None, 10, 1024) 2048 Encoder-19-FeedForward-Add[0][0]
__________________________________________________________________________________________________
Encoder-20-MultiHeadSelfAttenti (None, 10, 1024) 4198400 Encoder-19-FeedForward-Norm[0][0]
__________________________________________________________________________________________________
Encoder-20-MultiHeadSelfAttenti (None, 10, 1024) 0 Encoder-20-MultiHeadSelfAttention
__________________________________________________________________________________________________
Encoder-20-MultiHeadSelfAttenti (None, 10, 1024) 0 Encoder-19-FeedForward-Norm[0][0]
Encoder-20-MultiHeadSelfAttention
__________________________________________________________________________________________________
Encoder-20-MultiHeadSelfAttenti (None, 10, 1024) 2048 Encoder-20-MultiHeadSelfAttention
__________________________________________________________________________________________________
Encoder-20-FeedForward (FeedFor (None, 10, 1024) 8393728 Encoder-20-MultiHeadSelfAttention
__________________________________________________________________________________________________
Encoder-20-FeedForward-Dropout (None, 10, 1024) 0 Encoder-20-FeedForward[0][0]
__________________________________________________________________________________________________
Encoder-20-FeedForward-Add (Add (None, 10, 1024) 0 Encoder-20-MultiHeadSelfAttention
Encoder-20-FeedForward-Dropout[0]
__________________________________________________________________________________________________
Encoder-20-FeedForward-Norm (La (None, 10, 1024) 2048 Encoder-20-FeedForward-Add[0][0]
__________________________________________________________________________________________________
Encoder-21-MultiHeadSelfAttenti (None, 10, 1024) 4198400 Encoder-20-FeedForward-Norm[0][0]
__________________________________________________________________________________________________
Encoder-21-MultiHeadSelfAttenti (None, 10, 1024) 0 Encoder-21-MultiHeadSelfAttention
__________________________________________________________________________________________________
Encoder-21-MultiHeadSelfAttenti (None, 10, 1024) 0 Encoder-20-FeedForward-Norm[0][0]
Encoder-21-MultiHeadSelfAttention
__________________________________________________________________________________________________
Encoder-21-MultiHeadSelfAttenti (None, 10, 1024) 2048 Encoder-21-MultiHeadSelfAttention
__________________________________________________________________________________________________
Encoder-21-FeedForward (FeedFor (None, 10, 1024) 8393728 Encoder-21-MultiHeadSelfAttention
__________________________________________________________________________________________________
Encoder-21-FeedForward-Dropout (None, 10, 1024) 0 Encoder-21-FeedForward[0][0]
__________________________________________________________________________________________________
Encoder-21-FeedForward-Add (Add (None, 10, 1024) 0 Encoder-21-MultiHeadSelfAttention
Encoder-21-FeedForward-Dropout[0]
__________________________________________________________________________________________________
Encoder-21-FeedForward-Norm (La (None, 10, 1024) 2048 Encoder-21-FeedForward-Add[0][0]
__________________________________________________________________________________________________
Encoder-22-MultiHeadSelfAttenti (None, 10, 1024) 4198400 Encoder-21-FeedForward-Norm[0][0]
__________________________________________________________________________________________________
Encoder-22-MultiHeadSelfAttenti (None, 10, 1024) 0 Encoder-22-MultiHeadSelfAttention
__________________________________________________________________________________________________
Encoder-22-MultiHeadSelfAttenti (None, 10, 1024) 0 Encoder-21-FeedForward-Norm[0][0]
Encoder-22-MultiHeadSelfAttention
__________________________________________________________________________________________________
Encoder-22-MultiHeadSelfAttenti (None, 10, 1024) 2048 Encoder-22-MultiHeadSelfAttention
__________________________________________________________________________________________________
Encoder-22-FeedForward (FeedFor (None, 10, 1024) 8393728 Encoder-22-MultiHeadSelfAttention
__________________________________________________________________________________________________
Encoder-22-FeedForward-Dropout (None, 10, 1024) 0 Encoder-22-FeedForward[0][0]
__________________________________________________________________________________________________
Encoder-22-FeedForward-Add (Add (None, 10, 1024) 0 Encoder-22-MultiHeadSelfAttention
Encoder-22-FeedForward-Dropout[0]
__________________________________________________________________________________________________
Encoder-22-FeedForward-Norm (La (None, 10, 1024) 2048 Encoder-22-FeedForward-Add[0][0]
__________________________________________________________________________________________________
Encoder-23-MultiHeadSelfAttenti (None, 10, 1024) 4198400 Encoder-22-FeedForward-Norm[0][0]
__________________________________________________________________________________________________
Encoder-23-MultiHeadSelfAttenti (None, 10, 1024) 0 Encoder-23-MultiHeadSelfAttention
__________________________________________________________________________________________________
Encoder-23-MultiHeadSelfAttenti (None, 10, 1024) 0 Encoder-22-FeedForward-Norm[0][0]
Encoder-23-MultiHeadSelfAttention
__________________________________________________________________________________________________
Encoder-23-MultiHeadSelfAttenti (None, 10, 1024) 2048 Encoder-23-MultiHeadSelfAttention
__________________________________________________________________________________________________
Encoder-23-FeedForward (FeedFor (None, 10, 1024) 8393728 Encoder-23-MultiHeadSelfAttention
__________________________________________________________________________________________________
Encoder-23-FeedForward-Dropout (None, 10, 1024) 0 Encoder-23-FeedForward[0][0]
__________________________________________________________________________________________________
Encoder-23-FeedForward-Add (Add (None, 10, 1024) 0 Encoder-23-MultiHeadSelfAttention
Encoder-23-FeedForward-Dropout[0]
__________________________________________________________________________________________________
Encoder-23-FeedForward-Norm (La (None, 10, 1024) 2048 Encoder-23-FeedForward-Add[0][0]
__________________________________________________________________________________________________
Encoder-24-MultiHeadSelfAttenti (None, 10, 1024) 4198400 Encoder-23-FeedForward-Norm[0][0]
__________________________________________________________________________________________________
Encoder-24-MultiHeadSelfAttenti (None, 10, 1024) 0 Encoder-24-MultiHeadSelfAttention
__________________________________________________________________________________________________
Encoder-24-MultiHeadSelfAttenti (None, 10, 1024) 0 Encoder-23-FeedForward-Norm[0][0]
Encoder-24-MultiHeadSelfAttention
__________________________________________________________________________________________________
Encoder-24-MultiHeadSelfAttenti (None, 10, 1024) 2048 Encoder-24-MultiHeadSelfAttention
__________________________________________________________________________________________________
Encoder-24-FeedForward (FeedFor (None, 10, 1024) 8393728 Encoder-24-MultiHeadSelfAttention
__________________________________________________________________________________________________
Encoder-24-FeedForward-Dropout (None, 10, 1024) 0 Encoder-24-FeedForward[0][0]
__________________________________________________________________________________________________
Encoder-24-FeedForward-Add (Add (None, 10, 1024) 0 Encoder-24-MultiHeadSelfAttention
Encoder-24-FeedForward-Dropout[0]
__________________________________________________________________________________________________
Encoder-24-FeedForward-Norm (La (None, 10, 1024) 2048 Encoder-24-FeedForward-Add[0][0]
__________________________________________________________________________________________________
Encoder-Output (Concatenate) (None, 10, 4096) 0 Encoder-21-FeedForward-Norm[0][0]
Encoder-22-FeedForward-Norm[0][0]
Encoder-23-FeedForward-Norm[0][0]
Encoder-24-FeedForward-Norm[0][0]
__________________________________________________________________________________________________
non_masking_layer (NonMaskingLa (None, 10, 4096) 0 Encoder-Output[0][0]
__________________________________________________________________________________________________
layer_blstm (Bidirectional) (None, 10, 256) 4326400 non_masking_layer[0][0]
__________________________________________________________________________________________________
layer_dropout (Dropout) (None, 10, 256) 0 layer_blstm[0][0]
__________________________________________________________________________________________________
layer_time_distributed (TimeDis (None, 10, 14) 3598 layer_dropout[0][0]
__________________________________________________________________________________________________
activation (Activation) (None, 10, 14) 0 layer_time_distributed[0][0]
==================================================================================================
Total params: 337,908,238
Trainable params: 4,329,998
Non-trainable params: 333,578,240
__________________________________________________________________________________________________
[['O', 'I-SS', 'O', 'O', 'I-SS', 'I-SS', 'I-SS', 'O', 'O']]
It seems the sequence_length=100
not working, and sequence_length set to 10 since most of your data length shorter than 10. Since BERT will add a special token [CLS]
at the start of the sequence, you get result with a length of 9.
Please run this code below and help me figure out is that an issue related to the save and load process.
import logging
logging.basicConfig(level='DEBUG')
from kashgari.corpus import CONLL2003ENCorpus
import kashgari
from kashgari.tasks.labeling import BiLSTM_Model
train_x, train_y = CONLL2003ENCorpus.load_data('train')
valid_x, valid_y = CONLL2003ENCorpus.load_data('valid')
test_x, test_y = CONLL2003ENCorpus.load_data('test')
bert_embed = BERTEmbedding('bert',
task=kashgari.LABELING,
sequence_length=100)
model = BiLSTM_Model(bert_embed)
model.build_model(train_x, train_y, valid_x, valid_y)
I get the exact output as I did in the last comment when running build model
I get the exact output as I did in the last comment when running build model
I have tried this code on colab, unable to reproduce the issue, here is the colab link. Maybe update to the 0.5.1 version then try again.
Regardless of my input len, and only when running predict, not eval, the output argmax will only return 9 labels.
It changes for each input sentence, but it will only return a maximum of 9 predictions.
It doesn't matter how the sentence changes, the labels will be correct, but only spit out 9 of them. I wasn't sure if this is a bug or a question, but if you need more information please let me know.