为现有的顺序模型增加权重

时间:2019-02-14 07:46:56

标签: tensorflow

我有一个使用Tensorflow.js训练的顺序模型,我想更改嵌入层输入维度的形状。

我本质上是在尝试向情绪分析器添加更多单词,而不是试图在模型创建时考虑每个可能的单词。

有一个getWeights方法,但它只返回有关模型各层的信息,我需要向量数组或类似的东西。

var tf = 
require("/Users/powermac/Dev/rateBot/node_modules/@tensorflow/tfjs-node/node_modules/@tensorflow/tfjs");
require("@tensorflow/tfjs-node");


a();

async function a() {
  let model = await tf.loadModel(
    `file:///Users/powermac/Dev/rateBot/models/zersum/model.json`
  );
  let weights = model.getWeights();
  console.log(weights[0]);
  // =>
  // {
  //     isDisposedInternal: false,
  //         shape: [32982, 64],   // <=== Need to change this shape to [32983, 64]
  //             dtype: 'float32',
  //                 size: 2110848,
  //                     strides: [64],
  //                         dataId: { },
  //     id: 1,
  //         rankType: '2',
  //             trainable: true,
  //                 name: 'MyEmbedding/embeddings'
  // }
}

0 个答案:

没有答案
相关问题