def __init__(self, vocab_size, max_num_hidden_layers, embedding_dim, n_classes, output_dim, dropout, batch_size, b=0.99, n=0.01, s=0.2, use_cuda=False): super().__init__(vocab_size, max_num_hidden_layers, embedding_dim, n_classes, output_dim, dropout, batch_size, b=b, n=n, s=s, use_cuda=use_cuda) self.e = Parameter(torch.tensor(e), requires_grad=False) self.arms_values = Parameter(torch.arange(n_classes), requires_grad=False) self.explorations_mab = [] for i in range(n_classes): self.explorations_mab.append(algs.ThompsomSampling(len(e)))
def __init__(self, features_size, max_num_hidden_layers, qtd_neuron_per_hidden_layer, n_classes, b=0.99, n=0.01, s=0.2, e=[0.5, 0.35, 0.2, 0.1, 0.05], use_cuda=False): super().__init__(features_size, max_num_hidden_layers, qtd_neuron_per_hidden_layer, n_classes, b=b, n=n, s=s, use_cuda=use_cuda) self.e = Parameter(torch.tensor(e), requires_grad=False) self.arms_values = Parameter(torch.arange(n_classes), requires_grad=False) self.explorations_mab = [] for i in range(n_classes): self.explorations_mab.append(algs.ThompsomSampling(len(e)))
def get_algorithm(self, name, number_of_arms): """ This method instantiate the algorithm class. :param name: Name of algorithm. :param number_of_arms: Number of arms. :return: Returns the algorithm instance. """ if name == 'ths': alg = algs.ThompsomSampling(number_of_arms) elif name == 'tuned': alg = algs.UCBTuned(number_of_arms) elif name == 'ucb1': alg = algs.UCB1(number_of_arms) return alg