/// <summary> /// Returns a randomly initialized tensor with values draft from the /// uniform distribution between minValue and maxValue. /// </summary> public static Edu.Stanford.Nlp.Neural.SimpleTensor Random(int numRows, int numCols, int numSlices, double minValue, double maxValue, Java.Util.Random rand) { Edu.Stanford.Nlp.Neural.SimpleTensor tensor = new Edu.Stanford.Nlp.Neural.SimpleTensor(numRows, numCols, numSlices); for (int i = 0; i < numSlices; ++i) { tensor.slices[i] = SimpleMatrix.Random(numRows, numCols, minValue, maxValue, rand); } return(tensor); }
/// <summary> /// Returns a new tensor which has the values of the original tensor /// scaled by /// <paramref name="scaling"/> /// . The original object is /// unaffected. /// </summary> public virtual Edu.Stanford.Nlp.Neural.SimpleTensor Scale(double scaling) { Edu.Stanford.Nlp.Neural.SimpleTensor result = new Edu.Stanford.Nlp.Neural.SimpleTensor(numRows, numCols, numSlices); for (int slice = 0; slice < numSlices; ++slice) { result.slices[slice] = slices[slice].Scale(scaling); } return(result); }
/// <summary>Performs elementwise multiplication on the tensors.</summary> /// <remarks> /// Performs elementwise multiplication on the tensors. The original /// objects are unaffected. /// </remarks> public virtual Edu.Stanford.Nlp.Neural.SimpleTensor ElementMult(Edu.Stanford.Nlp.Neural.SimpleTensor other) { if (other.numRows != numRows || other.numCols != numCols || other.numSlices != numSlices) { throw new ArgumentException("Sizes of tensors do not match. Our size: " + numRows + "," + numCols + "," + numSlices + "; other size " + other.numRows + "," + other.numCols + "," + other.numSlices); } Edu.Stanford.Nlp.Neural.SimpleTensor result = new Edu.Stanford.Nlp.Neural.SimpleTensor(numRows, numCols, numSlices); for (int i = 0; i < numSlices; ++i) { result.slices[i] = slices[i].ElementMult(other.slices[i]); } return(result); }