本文整理了Java中org.nd4j.linalg.factory.Nd4j.tensorMmul()
方法的一些代码示例,展示了Nd4j.tensorMmul()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Nd4j.tensorMmul()
方法的具体详情如下:
包路径:org.nd4j.linalg.factory.Nd4j
类名称:Nd4j
方法名:tensorMmul
[英]Tensor matrix multiplication. Both tensors must be the same rank
[中]张量矩阵乘法。两个张量的秩必须相同
代码示例来源:origin: deeplearning4j/nd4j
/**
* Take the data that has been transformed to the principal components about the mean and
* transform it back into the original feature set. Make sure to fill in zeroes in columns
* where components were dropped!
* @param data Data of the same features used to construct the PCA object but as the components
* @return The records in terms of the original features
*/
public INDArray convertBackToFeatures(INDArray data) {
return Nd4j.tensorMmul(eigenvectors, data, new int[][] {{1}, {1}}).transposei().addiRowVector(mean);
}
代码示例来源:origin: deeplearning4j/nd4j
/**
* Takes a set of data on each row, with the same number of features as the constructing data
* and returns the data in the coordinates of the basis set about the mean.
* @param data Data of the same features used to construct the PCA object
* @return The record in terms of the principal component vectors, you can set unused ones to zero.
*/
public INDArray convertToComponents(INDArray data) {
INDArray dx = data.subRowVector(mean);
return Nd4j.tensorMmul(eigenvectors.transpose(), dx, new int[][] {{1}, {1}}).transposei();
}
代码示例来源:origin: deeplearning4j/nd4j
/**
* Generates a set of <i>count</i> random samples with the same variance and mean and eigenvector/values
* as the data set used to initialize the PCA object, with same number of features <i>N</i>.
* @param count The number of samples to generate
* @return A matrix of size <i>count</i> rows by <i>N</i> columns
*/
public INDArray generateGaussianSamples(long count) {
INDArray samples = Nd4j.randn(new long[] {count, eigenvalues.columns()});
INDArray factors = Transforms.pow(eigenvalues, -0.5, true);
samples.muliRowVector(factors);
return Nd4j.tensorMmul(eigenvectors, samples, new int[][] {{1}, {1}}).transposei().addiRowVector(mean);
}
代码示例来源:origin: org.nd4j/nd4j-api
@Override
public void exec() {
if(this.z != null)
this.z.assign(Nd4j.tensorMmul(x,y,z,axes));
else
this.z = Nd4j.tensorMmul(x,y,axes);
}
代码示例来源:origin: improbable-research/keanu
@Override
public IntegerTensor tensorMultiply(IntegerTensor value, int[] dimLeft, int[] dimsRight) {
INDArray tensorMmulResult = Nd4j.tensorMmul(tensor, unsafeGetNd4J(value), new int[][]{dimLeft, dimsRight});
return new Nd4jIntegerTensor(tensorMmulResult);
}
代码示例来源:origin: improbable-research/keanu
@Override
public DoubleTensor tensorMultiply(DoubleTensor value, int[] dimsLeft, int[] dimsRight) {
INDArray tensorMmulResult = Nd4j.tensorMmul(tensor, unsafeGetNd4J(value), new int[][]{dimsLeft, dimsRight});
return new Nd4jDoubleTensor(tensorMmulResult);
}
代码示例来源:origin: org.nd4j/nd4j-api
/**
* Take the data that has been transformed to the principal components about the mean and
* transform it back into the original feature set. Make sure to fill in zeroes in columns
* where components were dropped!
* @param data Data of the same features used to construct the PCA object but as the components
* @return The records in terms of the original features
*/
public INDArray convertBackToFeatures(INDArray data) {
return Nd4j.tensorMmul(eigenvectors, data, new int[][] {{1}, {1}}).transposei().addiRowVector(mean);
}
代码示例来源:origin: org.nd4j/nd4j-api
/**
* Takes a set of data on each row, with the same number of features as the constructing data
* and returns the data in the coordinates of the basis set about the mean.
* @param data Data of the same features used to construct the PCA object
* @return The record in terms of the principal component vectors, you can set unused ones to zero.
*/
public INDArray convertToComponents(INDArray data) {
INDArray dx = data.subRowVector(mean);
return Nd4j.tensorMmul(eigenvectors.transpose(), dx, new int[][] {{1},{1}}).transposei();
}
代码示例来源:origin: org.nd4j/nd4j-api
/**
* Generates a set of <i>count</i> random samples with the same variance and mean and eigenvector/values
* as the data set used to initialize the PCA object, with same number of features <i>N</i>.
* @param count The number of samples to generate
* @return A matrix of size <i>count</i> rows by <i>N</i> columns
*/
public INDArray generateGaussianSamples(int count) {
INDArray samples = Nd4j.randn(count, eigenvalues.columns());
INDArray factors = Transforms.pow(eigenvalues, -0.5, true);
samples.muliRowVector(factors);
return Nd4j.tensorMmul(eigenvectors, samples, new int[][] {{1}, {1}}).transposei().addiRowVector(mean);
}
内容来源于网络,如有侵权,请联系作者删除!