def test_classif(self, cls_data): X, Y = cls_data Xc = X.cuda() Yc = Y.cuda() kernel = kernels.GaussianKernel(2.0) torch.manual_seed(13) np.random.seed(13) def error_fn(t, p): return 100 * torch.sum(t * p <= 0).to( torch.float32) / t.shape[0], "c-err" opt = FalkonOptions(use_cpu=False, keops_active="no", debug=True) M = 500 flkc = InCoreFalkon(kernel=kernel, penalty=1e-6, M=M, seed=10, options=opt, maxiter=20, error_fn=error_fn) flkc.fit(Xc, Yc) cpreds = flkc.predict(Xc) assert cpreds.device == Xc.device err = error_fn(cpreds, Yc)[0] assert err < 5
def test_fails_cpu_tensors(self, cls_data): X, Y = cls_data kernel = kernels.GaussianKernel(2.0) opt = FalkonOptions(use_cpu=False, keops_active="no", debug=True) flk = InCoreFalkon(kernel=kernel, penalty=1e-6, M=500, seed=10, options=opt) with pytest.raises(ValueError): flk.fit(X, Y) flk.fit(X.cuda(), Y.cuda()) with pytest.raises(ValueError): flk.predict(X)