@Override
    public INDArray bilinearProducts(INDArray curr, INDArray in) {
        assert curr.shape().length == 3;
        if (in.columns() != 1) {
            throw new AssertionError("Expected a column vector");
        }
        if (in.rows() != curr.size(curr.shape().length - 1)) {
            throw new AssertionError("Number of rows in the input does not match number of columns in tensor");
        }


        if (curr.size(curr.shape().length - 2) != curr.size(curr.shape().length - 1)) {
            throw new AssertionError("Can only perform this operation on a SimpleTensor with square slices");
        }

        INDArray ret = Nd4j.create(curr.slices(), 1);
        INDArray inT = in.transpose();
        for (int i = 0; i < curr.slices(); i++) {
            INDArray slice = curr.slice(i);
            INDArray inTTimesSlice = inT.mmul(slice);
            ret.putScalar(i, Nd4j.getBlasWrapper().dot(inTTimesSlice, in));
        }
        return ret;
    }
@Override
    public INDArray bilinearProducts(INDArray curr, INDArray in) {
        assert curr.shape().length == 3;
        if (in.columns() != 1) {
            throw new AssertionError("Expected a column vector");
        }
        if (in.rows() != curr.size(curr.shape().length - 1)) {
            throw new AssertionError("Number of rows in the input does not match number of columns in tensor");
        }


        if (curr.size(curr.shape().length - 2) != curr.size(curr.shape().length - 1)) {
            throw new AssertionError("Can only perform this operation on a SimpleTensor with square slices");
        }

        INDArray ret = Nd4j.create(curr.slices(), 1);
        INDArray inT = in.transpose();
        for (int i = 0; i < curr.slices(); i++) {
            INDArray slice = curr.slice(i);
            INDArray inTTimesSlice = inT.mmul(slice);
            ret.putScalar(i, Nd4j.getBlasWrapper().dot(inTTimesSlice, in));
        }
        return ret;
    }
@ Override public INDArray bilinearProducts ( INDArray curr , INDArray in ) { assert curr . shape ( ) . length == 3 ; if ( in . columns ( ) != 1 ) { throw new AssertionError ( "Expected a column vector" ) ; } if ( in . rows ( ) != curr . size ( curr . shape ( ) . length - 1 ) ) { throw new AssertionError ( "Number of rows in the input does not match number of columns in tensor" ) ; } if ( curr . size ( curr . shape ( ) . length - 2 ) != curr . size ( curr . shape ( ) . length - 1 ) ) { throw new AssertionError ( "Can only perform this operation on a SimpleTensor with square slices" ) ; } INDArray ret = Nd4j . create ( curr . slices ( ) , 1 ) ; INDArray inT = in . transpose ( ) ; for ( int i = 0 ; i < curr . slices ( ) ; i ++ ) { INDArray slice = curr . slice ( i ) ; INDArray inTTimesSlice = inT . mmul ( slice ) ; ret . putScalar ( i , Nd4j . getBlasWrapper ( ) . dot ( inTTimesSlice , in ) ) ; } return ret ; }
Returns a column vector where each entry is the nth bilinear
product of the nth slices of the two tensors.
Returns a column vector where each entry is the nth bilinear product of the nth slices of the two tensors .