else:
raise TypeError("Layer must be of type str or int")
return model_outputs[layer_index].detach().cpu().numpy()
def set_learning_phase(self, train):
Set the learning phase for the backend framework.
After Change
num_batch = int(np.ceil(len(x_) / float(batch_size)))
for m in range(num_batch):
// Batch indexes
begin, end = m * batch_size, min((m + 1) * batch_size, x_.shape[0])
// Run prediction for the current batch
layer_output = self._model(torch.from_numpy(x_[begin:end]).to(self._device).float())[layer_index]
results.append(layer_output.detach().cpu().numpy())