162 SIZE_CHECK(batchX1.size2() == batchX2.size2());
163 std::size_t sizeX1=batchX1.size1();
164 std::size_t sizeX2=batchX2.size1();
167 InternalState& s=state.
toState<InternalState>();
168 s.resize(sizeX1,sizeX2);
171 noalias(s.norm2)=distanceSqr(batchX1,batchX2);
172 noalias(s.expNorm)=exp(-
m_gamma*s.norm2);
185 RealMatrix
const& coefficients,
189 std::size_t sizeX1=batchX1.size1();
190 std::size_t sizeX2=batchX2.size1();
191 InternalState
const& s = state.
toState<InternalState>();
194 SIZE_CHECK(batchX1.size2() == batchX2.size2());
201 gradient(0)= - sum(coefficients *s.expNorm * s.norm2);
209 RealMatrix
const& coefficientsX2,
213 std::size_t sizeX1=batchX1.size1();
214 std::size_t sizeX2=batchX2.size1();
215 InternalState
const& s = state.
toState<InternalState>();
218 SIZE_CHECK(batchX1.size2() == batchX2.size2());
224 gradient.resize(sizeX1,batchX1.size2());
225 RealMatrix W = coefficientsX2*s.expNorm;
226 noalias(gradient) = prod(W,batchX2);
227 RealVector columnSum = sum(as_rows(coefficientsX2*s.expNorm));
229 for(std::size_t i = 0; i != sizeX1; ++i){
230 noalias(row(gradient,i)) -= columnSum(i) * row(batchX1,i);