Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/396.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/tensorflow/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
JavaScript中的tf.keras.preprocessing.sequence.pad_序列_Javascript_Tensorflow_Keras_Tensorflow.js - Fatal编程技术网

JavaScript中的tf.keras.preprocessing.sequence.pad_序列

JavaScript中的tf.keras.preprocessing.sequence.pad_序列,javascript,tensorflow,keras,tensorflow.js,Javascript,Tensorflow,Keras,Tensorflow.js,如何在TensorFlow.js中实现tf.keras.preprocessing.sequence.pad_序列 encoded_text = tokenizer.texts_to_sequences([input_text])[0] pad_encoded = pad_sequences([encoded_text], maxlen=seq_len, truncating='pre') 可以使用将文本转换为张量 require('@tensorflow/tfjs'); const use

如何在TensorFlow.js中实现tf.keras.preprocessing.sequence.pad_序列

encoded_text = tokenizer.texts_to_sequences([input_text])[0]
pad_encoded = pad_sequences([encoded_text], maxlen=seq_len, truncating='pre')
可以使用将文本转换为张量

require('@tensorflow/tfjs');
const use = require('@tensorflow-models/universal-sentence-encoder');

use.load().then(model => {
  // Embed an array of sentences.
  const sentences = [
    'Hello.',
    'How are you?'
  ];
  model.embed(sentences).then(embeddings => {
    // `embeddings` is a 2D tensor consisting of the 512-dimensional embeddings for each sentence.
    // So in this example `embeddings` has the shape [2, 512].
    embeddings.print(true /* verbose */);
  });
});
tf.pad
稍后可用于填充张量