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
| name: Production Build | |
| on: | |
| pull_request: | |
| push: | |
| branches: | |
| - master |
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
| function run() { | |
| Promise.all([ | |
| encodeData(comments), | |
| encodeData(comment_testing) | |
| ]) | |
| .then(data => { | |
| const { | |
| 0: training_data, | |
| 1: testing_data, | |
| } = data; |
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
| const model = tf.sequential(); | |
| // Add layers to the model | |
| model.add(tf.layers.dense({ | |
| inputShape: [512], | |
| activation: 'sigmoid', | |
| units: 2, | |
| })); | |
| model.add(tf.layers.dense({ |
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
| const outputData = tf.tensor2d(comments.map(comment => [ | |
| comment.intent === 'buy' ? 1 : 0, | |
| comment.intent === 'none' ? 1 : 0, | |
| ])); | |
| // Output: [1,0] or [0,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
| const encodeData = data => { | |
| const sentences = data.map(comment => comment.text.toLowerCase()); | |
| const trainingData = use.load() | |
| .then(model => { | |
| return model.embed(sentences) | |
| .then(embeddings => { | |
| return embeddings; | |
| }); | |
| }) | |
| .catch(err => console.error('Fit Error:', err)); |
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 * as tf from '@tensorflow/tfjs'; | |
| import '@tensorflow/tfjs-node'; | |
| import * as use from '@tensorflow-models/universal-sentence-encoder'; | |
| import comments from './comment-training.json'; | |
| import comment_testing from './comment-test.json'; |
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
| [ | |
| { | |
| "text": "where can I buy your dress?", | |
| "intent": "buy" | |
| }, | |
| { | |
| "text": "how much was that dress?", | |
| "intent": "buy" | |
| }, | |
| { |
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
| [ | |
| { | |
| "text": "Woah yess❤️❤️", | |
| "intent": "none" | |
| }, | |
| { | |
| "text": "Happy birthday to the most beautiful woman on Instagram ! 💗💗", | |
| "intent": "none" | |
| }, | |
| { |
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
| [ | |
| { | |
| "text": "buy", | |
| "intent": "buy" | |
| }, | |
| { | |
| "text": "buying", | |
| "intent": "buy" | |
| }, | |
| { |
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 * as tf from '@tensorflow/tfjs'; | |
| import '@tensorflow/tfjs-node'; | |
| import * as use from '@tensorflow-models/universal-sentence-encoder'; |
NewerOlder