def get_training_data(num_samples):
"""Generates some training data."""
# As (x, y) Cartesian coordinates.
x = np.random.randint(0, 2, size=(num_samples, 2))
y = x[:, 0] + 2 * x[:, 1] # 2-digit binary to integer.
y = np.cast['int32'](y)
x = np.cast['float32'](x) * 1.6 - 0.8 # Scales to [-1, 1].
x += np.random.uniform(-0.1, 0.1, size=x.shape)
y_ohe = np.cast['float32'](np.eye(4)[y])
y = np.cast['float32'](np.expand_dims(y, -1))
return x, y, y_ohe
评论列表
文章目录