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

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

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

Nd4j.diag介绍

[英]Creates a new matrix where the values of the given vector are the diagonal values of the matrix if a vector is passed in, if a matrix is returns the kth diagonal in the matrix
[中]创建一个新矩阵,其中给定向量的值是矩阵的对角值(如果传入向量,则返回矩阵中的第k个对角)

代码示例

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

  1. /**
  2. * Creates a new matrix where the values of the given vector are the diagonal values of
  3. * the matrix if a vector is passed in, if a matrix is returns the kth diagonal
  4. * in the matrix
  5. *
  6. * @param x the diagonal values
  7. * @return new matrix
  8. */
  9. public static IComplexNDArray diag(IComplexNDArray x) {
  10. return diag(x, 0);
  11. }

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

  1. /**
  2. * Creates a new matrix where the values of the given vector are the diagonal values of
  3. * the matrix if a vector is passed in, if a matrix is returns the kth diagonal
  4. * in the matrix
  5. *
  6. * @param x the diagonal values
  7. * @return new matrix
  8. */
  9. public static INDArray diag(INDArray x) {
  10. return diag(x, 0);
  11. }

代码示例来源:origin: deeplearning4j/dl4j-examples

  1. INDArray linspace = Nd4j.linspace(1,10,10); //Values 1 to 10, in 10 steps
  2. System.out.println("Nd4j.linspace(1,10,10):\n" + linspace);
  3. INDArray diagMatrix = Nd4j.diag(rowVector2); //Create square matrix, with rowVector2 along the diagonal
  4. System.out.println("Nd4j.diag(rowVector2):\n" + diagMatrix);

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

  1. /**
  2. *
  3. * @param func
  4. * @param x0
  5. * @param f0
  6. * @param h
  7. * @param oneSided
  8. * @return
  9. */
  10. public static INDArray denseDifference(Function<INDArray,INDArray> func,
  11. INDArray x0,INDArray f0,
  12. INDArray h,INDArray oneSided) {
  13. INDArray hVecs = Nd4j.diag(h.reshape(1,h.length()));
  14. INDArray dx,df,x;
  15. INDArray jTransposed = Nd4j.create(x0.length(),f0.length());
  16. for(int i = 0; i < h.length(); i++) {
  17. INDArray hVecI = hVecs.slice(i);
  18. x = (x0.add(hVecI));
  19. dx = x.slice(i).sub(x0.slice(i));
  20. df = func.apply(x).sub(f0);
  21. INDArray div = df.div(dx);
  22. jTransposed.putSlice(i,div);
  23. }
  24. if(f0.length() == 1)
  25. jTransposed = jTransposed.ravel();
  26. return jTransposed;
  27. }

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

  1. return new IComplexNDArray[] {Nd4j.diag(E), V};

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

  1. /**
  2. * Creates a new matrix where the values of the given vector are the diagonal values of
  3. * the matrix if a vector is passed in, if a matrix is returns the kth diagonal
  4. * in the matrix
  5. *
  6. * @param x the diagonal values
  7. * @return new matrix
  8. */
  9. public static IComplexNDArray diag(IComplexNDArray x) {
  10. return diag(x, 0);
  11. }

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

  1. /**
  2. * Creates a new matrix where the values of the given vector are the diagonal values of
  3. * the matrix if a vector is passed in, if a matrix is returns the kth diagonal
  4. * in the matrix
  5. *
  6. * @param x the diagonal values
  7. * @return new matrix
  8. */
  9. public static INDArray diag(INDArray x) {
  10. return diag(x, 0);
  11. }

代码示例来源:origin: improbable-research/keanu

  1. @Override
  2. public IntegerTensor diag() {
  3. return new Nd4jIntegerTensor(Nd4j.diag(tensor));
  4. }

代码示例来源:origin: improbable-research/keanu

  1. @Override
  2. public DoubleTensor diag() {
  3. return new Nd4jDoubleTensor(Nd4j.diag(tensor));
  4. }

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

  1. return new IComplexNDArray[] {Nd4j.diag(E), V};

相关文章