• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

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

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: it

 it('should create three new tensors', () => {
   const input =
       tensor3d([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [3, 2, 2], 'int32');
   const numTensors: number = memory().numTensors;
   tensorArray.split([1, 1, 1], input);
   expect(memory().numTensors).toEqual(numTensors + 3);
 });
开发者ID:oveddan,项目名称:tfjs-converter,代码行数:7,代码来源:tensor_array_test.ts


示例2: extractParams

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

  const {
    extractMobilenetV1Params,
    extractPredictionLayerParams
  } = extractorsFactory(extractWeights)

  const mobilenetv1_params = extractMobilenetV1Params()
  const prediction_layer_params = extractPredictionLayerParams()
  const extra_dim = tf.tensor3d(
    extractWeights(5118 * 4),
    [1, 5118, 4]
  )
  const output_layer_params = {
    extra_dim
  }

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

  return {
    mobilenetv1_params,
    prediction_layer_params,
    output_layer_params
  }
}
开发者ID:BakirDiyar,项目名称:face-api.js,代码行数:31,代码来源:extractParams.ts


示例3: describe

describe('graph', () => {
  let node: Node;
  const input1 = [tfc.tensor1d([1])];
  const input2 = [tfc.tensor1d([1])];
  const input3 = [tfc.tensor3d([1, 1, 1, 2, 2, 2], [1, 2, 3])];
  const context = new ExecutionContext({}, {});

  beforeEach(() => {
    node = {
      name: 'input1',
      op: '',
      category: 'graph',
      inputNames: [],
      inputs: [],
      params: {},
      children: []
    };
  });

  describe('executeOp', () => {
    describe('const', () => {
      it('should return input', () => {
        node.op = 'const';
        expect(executeOp(node, {input1}, context)).toEqual(input1);
      });
    });
    describe('placeholder', () => {
      it('should return input', () => {
        node.op = 'placeholder';
        expect(executeOp(node, {input1}, context)).toEqual(input1);
      });
      it('should return default if input not set', () => {
        node.inputNames = ['input2'];
        node.op = 'placeholder';
        node.params.default = createTensorAttr(0);
        expect(executeOp(node, {input2}, context)).toEqual(input2);
      });
    });
    describe('identity', () => {
      it('should return input', () => {
        node.inputNames = ['input'];
        node.params.x = createTensorAttr(0);
        node.op = 'identity';
        expect(executeOp(node, {input: input1}, context)).toEqual(input1);
      });
    });
    describe('snapshot', () => {
      it('should return input', () => {
        node.inputNames = ['input'];
        node.params.x = createTensorAttr(0);
        node.op = 'snapshot';
        const result =
            (executeOp(node, {input: input1}, context) as tfc.Tensor[])[0];
        expect(result.rank).toEqual(input1[0].rank);
        test_util.expectArraysClose(result, [1]);
      });
    });
    describe('shape', () => {
      it('should return shape', () => {
        node.inputNames = ['input'];
        node.params.x = createTensorAttr(0);
        node.op = 'shape';
        expect(
            Array.prototype.slice.call(
                (executeOp(node, {input: input3}, context) as tfc.Tensor[])[0]
                    .dataSync()))
            .toEqual([1, 2, 3]);
      });
    });
    describe('size', () => {
      it('should return size', () => {
        node.inputNames = ['input'];
        node.params.x = createTensorAttr(0);
        node.op = 'size';
        expect(
            Array.prototype.slice.call(
                (executeOp(node, {input: input3}, context) as tfc.Tensor[])[0]
                    .dataSync()))
            .toEqual([6]);
      });
    });
    describe('rank', () => {
      it('should return rank', () => {
        node.inputNames = ['input'];
        node.params.x = createTensorAttr(0);
        node.op = 'rank';
        expect(
            Array.prototype.slice.call(
                (executeOp(node, {input: input3}, context) as tfc.Tensor[])[0]
                    .dataSync()))
            .toEqual([3]);
      });
    });
    describe('noop', () => {
      it('should return empty', () => {
        node.op = 'noop';
        expect(executeOp(node, {}, context)).toEqual([]);
      });
    });
  });
//.........这里部分代码省略.........
开发者ID:oveddan,项目名称:tfjs-converter,代码行数:101,代码来源:graph_executor_test.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript tfjs-core.tensor4d函数代码示例发布时间:2022-05-28
下一篇:
TypeScript tfjs-core.tensor2d函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap