当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript tfjs-core.tensor2d函数代码示例

本文整理汇总了TypeScript中@tensorflow/tfjs-core.tensor2d函数的典型用法代码示例。如果您正苦于以下问题:TypeScript tensor2d函数的具体用法?TypeScript tensor2d怎么用?TypeScript tensor2d使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了tensor2d函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: beforeEach

 beforeEach(() => {
   tensorArray = new TensorArray(
       NAME, DTYPE, SIZE, SHAPE, IDENTICAL_SHAPE, DYNAMIC_SIZE,
       CLEAR_AFTER_READ);
   tensor = tensor2d([1], [1, 1], 'int32');
   tensor2 = tensor2d([2], [1, 1], 'int32');
 });
开发者ID:oveddan,项目名称:tfjs-converter,代码行数:7,代码来源:tensor_array_test.ts

示例2: extractFcParams

 function extractFcParams(channelsIn: number, channelsOut: number,): FCParams {
   const fc_weights = tf.tensor2d(extractWeights(channelsIn * channelsOut), [channelsIn, channelsOut])
   const fc_bias = tf.tensor1d(extractWeights(channelsOut))
   return {
     weights: fc_weights,
     bias: fc_bias
   }
 }
开发者ID:BakirDiyar,项目名称:face-api.js,代码行数:8,代码来源:extractParams.ts

示例3: it

 it('should generate the output array', async () => {
   await model.load();
   const input = tfc.tensor2d([1, 1], [2, 1], 'int32');
   const output = model.execute({'Input': input}, ['Add', 'Const']);
   expect(Array.isArray(output)).toBeTruthy();
   expect((output as tfc.Tensor[])[0].dataSync()[0]).toEqual(2);
   expect((output as tfc.Tensor[])[1].dataSync()[0]).toEqual(1);
 });
开发者ID:oveddan,项目名称:tfjs-converter,代码行数:8,代码来源:frozen_model_test.ts

示例4: generateAtlas

 generateAtlas() {
   for (let i = 0; i < this.atlasSize; ++i) {
     const distribution = this.sampleFromTrueDistribution(
       this.selectedShapeName, this.drawingPositions);
     this.inputAtlasList.push(distribution[0]);
     this.inputAtlasList.push(distribution[1]);
   }
   this.atlas = tf.tensor2d(this.inputAtlasList, [this.atlasSize, 2]);
 }
开发者ID:deepkapha,项目名称:dklabs.github.io,代码行数:9,代码来源:ganlab_input_providers.ts

示例5: extractParams

export function extractParams(weights: Float32Array): NetParams {
  const {
    extractWeights,
    getRemainingWeights
  } = extractWeightsFactory(weights)

  const {
    extractConvLayerParams,
    extractResidualLayerParams
  } = extractorsFactory(extractWeights)

  const conv32_down = extractConvLayerParams(4704, 32, 7)
  const conv32_1 = extractResidualLayerParams(9216, 32, 3)
  const conv32_2 = extractResidualLayerParams(9216, 32, 3)
  const conv32_3 = extractResidualLayerParams(9216, 32, 3)

  const conv64_down = extractResidualLayerParams(36864, 64, 3, true)
  const conv64_1 = extractResidualLayerParams(36864, 64, 3)
  const conv64_2 = extractResidualLayerParams(36864, 64, 3)
  const conv64_3 = extractResidualLayerParams(36864, 64, 3)

  const conv128_down = extractResidualLayerParams(147456, 128, 3, true)
  const conv128_1 = extractResidualLayerParams(147456, 128, 3)
  const conv128_2 = extractResidualLayerParams(147456, 128, 3)

  const conv256_down = extractResidualLayerParams(589824, 256, 3, true)
  const conv256_1 = extractResidualLayerParams(589824, 256, 3)
  const conv256_2 = extractResidualLayerParams(589824, 256, 3)
  const conv256_down_out = extractResidualLayerParams(589824, 256, 3)

  const fc = tf.transpose(tf.tensor2d(extractWeights(256 * 128), [128, 256]), [1, 0])

  if (getRemainingWeights().length !== 0) {
    throw new Error(`weights remaing after extract: ${getRemainingWeights().length}`)
  }

  return {
    conv32_down,
    conv32_1,
    conv32_2,
    conv32_3,
    conv64_down,
    conv64_1,
    conv64_2,
    conv64_3,
    conv128_down,
    conv128_1,
    conv128_2,
    conv256_down,
    conv256_1,
    conv256_2,
    conv256_down_out,
    fc
  }
}
开发者ID:BakirDiyar,项目名称:face-api.js,代码行数:55,代码来源:extractParams.ts

示例6: it

      it('should call tfc.pad', () => {
        spyOn(tfc, 'pad');
        node.op = 'pad';
        node.params.padding = createNumericArrayAttrFromIndex(1);
        node.params.constantValue = createNumberAttr(1);
        node.inputNames = ['input1', 'input3'];
        const input3 = [tfc.tensor2d([1, 1, 2, 2], [2, 2])];
        executeOp(node, {input1, input3}, context);

        expect(tfc.pad).toHaveBeenCalledWith(input1[0], [[1, 1], [2, 2]], 1);
      });
开发者ID:oveddan,项目名称:tfjs-converter,代码行数:11,代码来源:transformation_executor_test.ts

示例7: it

      it('should split the tensor to tensorArray', async () => {
        const tensorArray =
            new TensorArray('', 'int32', 2, [3], true, false, true);
        const input4 = [tensor2d([0, 0, 0, 1, 1, 1], [2, 3], 'int32')];
        context.addTensorArray(tensorArray);
        node.op = 'tensorArraySplit';
        node.params['tensorArrayId'] = createNumberAttrFromIndex(0);
        node.params['tensor'] = createTensorAttr(1);
        node.params['lengths'] = createNumericArrayAttrFromIndex(2);
        node.inputNames = ['input2', 'input4', 'input3'];
        const input2 = [scalar(tensorArray.id)];
        const input3 = [tensor1d([1, 1], 'int32')];
        await executeOp(node, {input2, input3, input4}, context);

        expect(tensorArray.size()).toEqual(2);
      });
开发者ID:oveddan,项目名称:tfjs-converter,代码行数:16,代码来源:control_executor_test.ts


注:本文中的@tensorflow/tfjs-core.tensor2d函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。