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


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

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


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

示例1: extractFilterValues

  function extractFilterValues(numFilterValues: number, numFilters: number, filterSize: number): tf.Tensor4D {
    const weights = extractWeights(numFilterValues)
    const depth = weights.length / (numFilters * filterSize * filterSize)

    if (isFloat(depth)) {
      throw new Error(`depth has to be an integer: ${depth}, weights.length: ${weights.length}, numFilters: ${numFilters}, filterSize: ${filterSize}`)
    }

    return tf.transpose(
      tf.tensor4d(weights, [numFilters, depth, filterSize, filterSize]),
      [2, 3, 1, 0]
    )
  }
开发者ID:BakirDiyar,项目名称:face-api.js,代码行数:13,代码来源:extractParams.ts

示例2: it

    it('is padded to square by 2 columns', () => tf.tidy(() => {
      const imgTensor = tf.tensor4d(Array(24).fill(1), [1, 4, 2, 3])
      const result = padToSquare(imgTensor)

      expect(result.shape).toEqual([1, 4, 4, 3])

      const paddedCols = tf.unstack(result, 2)
      expect(paddedCols.length).toEqual(4)
      expect(paddedCols[0].dataSync()).toEqual(ones(12))
      expect(paddedCols[1].dataSync()).toEqual(ones(12))
      expect(paddedCols[2].dataSync()).toEqual(zeros(12))
      expect(paddedCols[3].dataSync()).toEqual(zeros(12))
    }))
开发者ID:BakirDiyar,项目名称:face-api.js,代码行数:13,代码来源:padToSquare.test.ts

示例3: extractDepthwiseConvParams

  function extractDepthwiseConvParams(numChannels: number): MobileNetV1.DepthwiseConvParams {
    const filters = tf.tensor4d(extractWeights(3 * 3 * numChannels), [3, 3, numChannels, 1])
    const batch_norm_scale = tf.tensor1d(extractWeights(numChannels))
    const batch_norm_offset = tf.tensor1d(extractWeights(numChannels))
    const batch_norm_mean = tf.tensor1d(extractWeights(numChannels))
    const batch_norm_variance = tf.tensor1d(extractWeights(numChannels))

    return {
      filters,
      batch_norm_scale,
      batch_norm_offset,
      batch_norm_mean,
      batch_norm_variance
    }
  }
开发者ID:BakirDiyar,项目名称:face-api.js,代码行数:15,代码来源:extractParams.ts

示例4: function

  return function (
    channelsIn: number,
    channelsOut: number,
    filterSize: number
  ): ConvParams {
    const filters = tf.tensor4d(
      extractWeights(channelsIn * channelsOut * filterSize * filterSize),
      [filterSize, filterSize, channelsIn, channelsOut]
    )
    const bias = tf.tensor1d(extractWeights(channelsOut))

    return {
      filters,
      bias
    }
  }
开发者ID:BakirDiyar,项目名称:face-api.js,代码行数:16,代码来源:extractConvParamsFactory.ts

示例5: it

 it('should not throw exception if inputs shapes is dynamic', () => {
   inputNode.params['shape'] = {value: [-1, 1, 1, 1], type: 'shape'};
   const inputTensor = tfc.tensor4d([1, 1], [2, 1, 1, 1], 'float32');
   expect(() => executor.execute({input: [inputTensor]})).not.toThrow();
 });
开发者ID:oveddan,项目名称:tfjs-converter,代码行数:5,代码来源:graph_executor_test.ts


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