def make_control_vectors(num_cv, pos_stddev, angle_stddev, scale_stddev):
"""
Argument num_cv is the approximate number of control vectors to create
Arguments pos_stddev, angle_stddev, and scale_stddev are the standard
deviations of the controls effects of position, angle, and
scale.
Returns pair of control_vectors, control_sdr
The control_vectors determines what happens for each output. Each
control is a 4-tuple of (X, Y, Angle, Scale) movements. To move,
active controls are summed and applied to the current location.
control_sdr contains the shape of the control_vectors.
"""
cv_sz = int(round(num_cv // 6))
control_shape = (6*cv_sz,)
pos_controls = [
(random.gauss(0, pos_stddev), random.gauss(0, pos_stddev), 0, 0)
for i in range(4*cv_sz)]
angle_controls = [
(0, 0, random.gauss(0, angle_stddev), 0)
for angle_control in range(cv_sz)]
scale_controls = [
(0, 0, 0, random.gauss(0, scale_stddev))
for scale_control in range(cv_sz)]
control_vectors = pos_controls + angle_controls + scale_controls
random.shuffle(control_vectors)
control_vectors = np.array(control_vectors)
# Add a little noise to all control vectors
control_vectors[:, 0] += np.random.normal(0, pos_stddev/10, control_shape)
control_vectors[:, 1] += np.random.normal(0, pos_stddev/10, control_shape)
control_vectors[:, 2] += np.random.normal(0, angle_stddev/10, control_shape)
control_vectors[:, 3] += np.random.normal(0, scale_stddev/10, control_shape)
return control_vectors, SDR(control_shape)
评论列表
文章目录