org.nd4j.linalg.factory.Nd4j.pile()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(2.3k)|赞(0)|评价(0)|浏览(137)

本文整理了Java中org.nd4j.linalg.factory.Nd4j.pile()方法的一些代码示例,展示了Nd4j.pile()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Nd4j.pile()方法的具体详情如下:
包路径:org.nd4j.linalg.factory.Nd4j
类名称:Nd4j
方法名:pile

Nd4j.pile介绍

[英]This method stacks vertically examples with the same shape, increasing result dimensionality. I.e. if you provide bunch of 3D tensors, output will be 4D tensor. Alignment is always applied to axis 0.
[中]此方法垂直堆叠具有相同形状的示例,增加结果维度。也就是说,如果您提供一组三维张量,输出将是4D张量。对齐始终应用于轴0。

代码示例

代码示例来源:origin: deeplearning4j/nd4j

  1. /**
  2. * This method stacks vertically examples with the same shape, increasing result dimensionality. I.e. if you provide bunch of 3D tensors, output will be 4D tensor. Alignment is always applied to axis 0.
  3. *
  4. * @return
  5. */
  6. public static INDArray pile(@NonNull Collection<INDArray> arrays) {
  7. return pile(arrays.toArray(new INDArray[0]));
  8. }

代码示例来源:origin: org.nd4j/nd4j-api

  1. /**
  2. * This method stacks vertically examples with the same shape, increasing result dimensionality. I.e. if you provide bunch of 3D tensors, output will be 4D tensor. Alignment is always applied to axis 0.
  3. *
  4. * @return
  5. */
  6. public static INDArray pile(@NonNull Collection<INDArray> arrays) {
  7. return pile(arrays.toArray(new INDArray[0]));
  8. }

代码示例来源:origin: org.deeplearning4j/deeplearning4j-parallel-wrapper_2.11

  1. @Override
  2. public INDArray[] getInput() {
  3. realLocker.writeLock().lock();
  4. isLocked.set(true);
  5. // this method should pile individual examples into single batch
  6. if (counter.get() > 1) {
  7. INDArray[] result = new INDArray[inputs.get(0).length];
  8. for (int i = 0; i < result.length; i++) {
  9. List<INDArray> examples = new ArrayList<>();
  10. for (int e = 0; e < inputs.size(); e++) {
  11. examples.add(inputs.get(e)[i]);
  12. }
  13. result[i] = Nd4j.pile(examples);
  14. }
  15. realLocker.writeLock().unlock();
  16. return result;
  17. } else {
  18. realLocker.writeLock().unlock();
  19. return inputs.get(0);
  20. }
  21. }

代码示例来源:origin: org.deeplearning4j/deeplearning4j-parallel-wrapper

  1. @Override
  2. public INDArray[] getInput() {
  3. realLocker.writeLock().lock();
  4. isLocked.set(true);
  5. // this method should pile individual examples into single batch
  6. if (counter.get() > 1) {
  7. INDArray[] result = new INDArray[inputs.get(0).length];
  8. for (int i = 0; i < result.length; i++) {
  9. List<INDArray> examples = new ArrayList<>();
  10. for (int e = 0; e < inputs.size(); e++) {
  11. examples.add(inputs.get(e)[i]);
  12. }
  13. result[i] = Nd4j.pile(examples);
  14. }
  15. realLocker.writeLock().unlock();
  16. return result;
  17. } else {
  18. realLocker.writeLock().unlock();
  19. return inputs.get(0);
  20. }
  21. }

相关文章