十进制转化为二进制,其中二进制为反序
# Represent each input by an array of its binary digits.
def binary_encode(i, num_digits):
return np.array([i >> d & 1 for d in range(num_digits)])
十进制转化为二进制,其中二进制为正序
def binary_encode(i, num_digits):
return np.array([i >> d & 1 for d in range(num_digits)][::-1])