private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); identity = SimpleMatrix.identity(numRows); }
identity = SimpleMatrix.identity(numHid);
public DVModel(TwoDimensionalMap<String, String, SimpleMatrix> binaryTransform, Map<String, SimpleMatrix> unaryTransform, TwoDimensionalMap<String, String, SimpleMatrix> binaryScore, Map<String, SimpleMatrix> unaryScore, Map<String, SimpleMatrix> wordVectors, Options op) { this.op = op; this.binaryTransform = binaryTransform; this.unaryTransform = unaryTransform; this.binaryScore = binaryScore; this.unaryScore = unaryScore; this.wordVectors = wordVectors; this.numBinaryMatrices = binaryTransform.size(); this.numUnaryMatrices = unaryTransform.size(); if (numBinaryMatrices > 0) { this.binaryTransformSize = binaryTransform.iterator().next().getValue().getNumElements(); this.binaryScoreSize = binaryScore.iterator().next().getValue().getNumElements(); } else { this.binaryTransformSize = 0; this.binaryScoreSize = 0; } if (numUnaryMatrices > 0) { this.unaryTransformSize = unaryTransform.values().iterator().next().getNumElements(); this.unaryScoreSize = unaryScore.values().iterator().next().getNumElements(); } else { this.unaryTransformSize = 0; this.unaryScoreSize = 0; } this.numRows = op.lexOptions.numHid; this.numCols = op.lexOptions.numHid; this.identity = SimpleMatrix.identity(numRows); this.rand = new Random(op.trainOptions.randomSeed); }
identity = SimpleMatrix.identity(numHid);
identity = SimpleMatrix.identity(numRows);
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); identity = SimpleMatrix.identity(numRows); }
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); identity = SimpleMatrix.identity(numRows); }
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); identity = SimpleMatrix.identity(numRows); }
private SimpleMatrix computeG( Point3D_F64 epipole , int x0 , int y0 ) { double x = epipole.x/epipole.z - x0; double y = epipole.y/epipole.z - y0; double f = Math.sqrt(x*x + y*y); SimpleMatrix G = SimpleMatrix.identity(3); G.set(2,0,-1.0/f); return G; }
private SimpleMatrix computeG( Point3D_F64 epipole , int x0 , int y0 ) { double x = epipole.x/epipole.z - x0; double y = epipole.y/epipole.z - y0; double f = Math.sqrt(x*x + y*y); SimpleMatrix G = SimpleMatrix.identity(3); G.set(2,0,-1.0/f); return G; }
/** * Create a transform which will move the specified point to the origin */ private SimpleMatrix translateToOrigin( int x0 , int y0 ) { SimpleMatrix T = SimpleMatrix.identity(3); T.set(0, 2, -x0); T.set(1, 2, -y0); return T; }
/** * Create a transform which will move the specified point to the origin */ private SimpleMatrix translateToOrigin( int x0 , int y0 ) { SimpleMatrix T = SimpleMatrix.identity(3); T.set(0, 2, -x0); T.set(1, 2, -y0); return T; }
private static SimpleMatrix projectBandwidthToOriginalSpace(SampleModel distribution, double bandwidthFactor) { SimpleMatrix bandwidth = SimpleMatrix.identity(distribution.getGlobalCovariance().numCols()); SimpleMatrix subSpaceBandwidth = distribution.getSubspaceGlobalCovariance().scale(Math.pow(bandwidthFactor, 2)); ArrayList<Integer> subspace = distribution.getmSubspace(); for (int i = 0; i < subSpaceBandwidth.numRows(); i++) { for (int j = 0; j < subSpaceBandwidth.numCols(); j++) { if (subspace.contains(new Integer(i)) && subspace.contains(new Integer(j))) bandwidth.set(i, j, subSpaceBandwidth.get(i, j)); } } SimpleMatrix invSubspaceCov = distribution.getSubspaceInverseCovariance(); bandwidth = invSubspaceCov.transpose().mult(bandwidth).mult(invSubspaceCov); return bandwidth; }
/** * Creates a Q matrix for debugging purposes. */ private SimpleMatrix createQ(int x1, int x2 , double c, double s , boolean transposed ) { SimpleMatrix Q = SimpleMatrix.identity(N); Q.set(x1,x1,c); if( transposed ) { Q.set(x1,x2,s); Q.set(x2,x1,-s); } else { Q.set(x1,x2,-s); Q.set(x2,x1,s); } Q.set(x2,x2,c); return Q; }
/** * Creates a Q matrix for debugging purposes. */ private SimpleMatrix createQ(int x1, int x2 , double c, double s , boolean transposed ) { SimpleMatrix Q = SimpleMatrix.identity(N); Q.set(x1,x1,c); if( transposed ) { Q.set(x1,x2,s); Q.set(x2,x1,-s); } else { Q.set(x1,x2,-s); Q.set(x2,x1,s); } Q.set(x2,x2,c); return Q; }
/** * Finds the values of a,b,c which minimize * * sum (a*x(+)_i + b*y(+)_i + c - x(-)_i)^2 * * See page 306 * * @return Affine transform */ private SimpleMatrix computeAffineH( List<AssociatedPair> observations , DenseMatrix64F H , DenseMatrix64F Hzero ) { SimpleMatrix A = new SimpleMatrix(observations.size(),3); SimpleMatrix b = new SimpleMatrix(A.numRows(),1); Point2D_F64 c = new Point2D_F64(); Point2D_F64 k = new Point2D_F64(); for( int i = 0; i < observations.size(); i++ ) { AssociatedPair a = observations.get(i); GeometryMath_F64.mult(Hzero, a.p1, k); GeometryMath_F64.mult(H,a.p2,c); A.setRow(i,0,k.x,k.y,1); b.set(i,0,c.x); } SimpleMatrix x = A.solve(b); SimpleMatrix Ha = SimpleMatrix.identity(3); Ha.setRow(0,0,x.getMatrix().data); return Ha; }