for key, bounds in self.coefficient_bounds.items():
min_value, max_value = bounds
m = torch.nn.Hardtanh(min_value, max_value)
# the input needs to be a tensor so we have to convert
# custom_pauli_coefficients[key] to a tensor
input = torch.tensor(custom_pauli_coefficients[key])
custom_pauli_coefficients[key] = m(input)
1条答案
按热度按时间e0bqpujr1#
我最终使用HardTanh与如下设置