56 blas::matrix_expression<M, Device>& matrix,
57 double regularizer = 0
63 std::vector<std::size_t> batchStart(B+1,0);
64 for(std::size_t i = 1; i != B+1; ++i){
68 std::size_t N = batchStart[B];
69 ensure_size(matrix,N,N);
72 for (std::size_t i=0; i<B; i++){
73 std::size_t startX = batchStart[i];
74 std::size_t endX = batchStart[i+1];
76 std::size_t startY = batchStart[j];
77 std::size_t endY = batchStart[j+1];
78 RealMatrix submatrix = kernel(dataset.
batch(i), dataset.
batch(j));
79 noalias(subrange(matrix(),startX,endX,startY,endY))=submatrix;
83 for(std::size_t k = startX; k != endX; ++k){
84 matrix()(k,k) +=
static_cast<typename M::value_type
>(regularizer);
101 blas::matrix_expression<M, Device>& matrix
107 std::vector<std::size_t> batchStart1(B1+1,0);
108 for(std::size_t i = 1; i != B1+1; ++i){
109 batchStart1[i] = batchStart1[i-1]+
batchSize(dataset1.
batch(i-1));
111 std::vector<std::size_t> batchStart2(B2+1,0);
112 for(std::size_t i = 1; i != B2+1; ++i){
113 batchStart2[i] = batchStart2[i-1]+
batchSize(dataset2.
batch(i-1));
117 std::size_t N1 = batchStart1[B1];
118 std::size_t N2 = batchStart2[B2];
119 ensure_size(matrix,N1,N2);
121 for (std::size_t i=0; i<B1; i++){
122 std::size_t startX = batchStart1[i];
123 std::size_t endX = batchStart1[i+1];
125 std::size_t startY = batchStart2[j];
126 std::size_t endY = batchStart2[j+1];
127 RealMatrix submatrix = kernel(dataset1.
batch(i), dataset2.
batch(j));
128 noalias(subrange(matrix(),startX,endX,startY,endY))=submatrix;
189 WeightMatrix
const& weights
193 RealVector kernelGradient(kp);
194 kernelGradient.clear();
197 RealVector blockGradient(kp);
198 boost::shared_ptr<State> state = kernel.
createState();
199 std::size_t startX = 0;
202 std::size_t startY = 0;
203 for (std::size_t j=0; j <= i; j++){
208 subrange(weights,startX,startX+sizeX,startY,startY+sizeY),
213 kernelGradient+=2*blockGradient;
215 kernelGradient+=blockGradient;
220 return kernelGradient;