This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| CLS_ID = tf.constant(101, dtype=tf.int64) | |
| SEP_ID = tf.constant(102, dtype=tf.int64) | |
| start_tokens = tf.fill([tf.shape(text)[0], 1], CLS_ID) | |
| end_tokens = tf.fill([tf.shape(text)[0], 1], SEP_ID) | |
| tokens = tokens[:, :sequence_length - 2] | |
| tokens = tf.concat([start_tokens, tokens, end_tokens], axis=1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| tokens = bert_tokenizer.tokenize(text) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| bert_tokenizer = text.BertTokenizer( | |
| vocab_lookup_table=vocab_file_path, | |
| token_out_type=tf.int64, | |
| lower_case=do_lower_case | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| do_lower_case = bert_layer.resolved_object.do_lower_case.numpy() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import tensorflow_hub as hub | |
| BERT_TFHUB_URL = "https://tfhub.dev/tensorflow/bert_en_uncased_L-12_H-768_A-12/2" | |
| bert_layer = hub.KerasLayer(handle=BERT_TFHUB_URL, trainable=True) | |
| vocab_file_path = bert_layer.resolved_object.vocab_file.asset_path.numpy() |
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ‘This is the best movie I have ever seen ...’ -> 1 | |
| ‘Probably the worst movie produced in 2019 ...’ -> 0 | |
| ‘Tom Hank\’s performance turns this movie into ...’ -> ? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import tensorflow_text as text | |
| vocab_file_path = bert_layer.resolved_object.vocab_file.asset_path.numpy() | |
| do_lower_case = bert_layer.resolved_object.do_lower_case.numpy() | |
| bert_tokenizer = text.BertTokenizer( | |
| vocab_lookup_table=vocab_file_path, | |
| token_out_type=tf.int64, | |
| lower_case=do_lower_case | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [ | |
| [[b'clara'], [b'is'], [b'playing'], [b'the'], [b'piano'], [b'.']], | |
| [[b'maria'], [b'likes'], [b'to'], [b'play'], [b'soccer'], [b'.']], | |
| [[b'hi'], [b'tom'], [b'!']] | |
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [ | |
| "Clara is playing the piano." | |
| "Maria likes to play soccer.", | |
| "Hi Tom!" | |
| ] |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.