test_bottom = fold * test_size
        test_top = (1 + fold) * test_size
        test_indices = shuffidx[test_bottom:test_top]
        train_indices = shuffidx[0:test_bottom] + shuffidx[test_top:]
        loss_func = []
        bfs_params = []
        test_loss = []

        torch.set_rng_state(rng_state)  #fix init state
        torch.manual_seed(0)
        pht = MP(rbf=bfs, filtername='f')

        optimizer_filter = optim.SGD([{'params': pht.rbfweights}], lr=lr)

        for epoch in range(max_epoch):
            pht.train()
            np.random.shuffle(train_indices)
            lss = 0

            for b in range(train_batches):

                bfs_params.append(pht.rbfweights.detach().clone().numpy())
                pht.train()
                train_indices_batch = train_indices[b * batch_size:(b + 1) *
                                                    batch_size]
                optimizer_filter.zero_grad()

                loss = pht([data[i] for i in train_indices_batch])

                loss.backward()
                optimizer_filter.step()