def DizzyLayerV2(X, rot_list, n):
n_prime = int(n*(n-1)/2)
thetas = tf.Variable(tf.random_uniform([n_prime, 1], 0, 2*math.pi), name="thetas")
results = [X]
k = 0
for sublist in rot_list:
indices = []
values = []
for (a, b) in sublist:
c = tf.cos(thetas[k])
s = tf.sin(thetas[k])
indices = indices + [[a, a], [a, b], [b, a], [b, b]]
values = values + [c, s, -s, c]
k += 1
shape = [n, n]
v = tf.pack(tf.squeeze(values))
R = tf.SparseTensor(indices, v, shape)
results.append(tf.sparse_tensor_dense_matmul(R, results[-1]))
return results[-1]
评论列表
文章目录