29f7321b64ada5e66ff4ba8e4c9d0a44fed241f4,t3f/initializers.py,,random_tensor_batch,#Any#Any#Any#Any#Any#,244
Before Change
tt_rank = np.append(tt_rank, 1)
tt_rank = tt_rank.astype(int)
// TODO: variable (name?) scope.
tt_cores = [None] * num_dims
for i in range(num_dims):
curr_core_shape = (batch_size, tt_rank[i], shape[i], tt_rank[i + 1])
tt_cores[i] = tf.random_normal(curr_core_shape, mean=mean, stddev=stddev)
return TensorTrainBatch(tt_cores, shape, tt_rank, batch_size)
def random_matrix(shape, tt_rank=2, mean=0., stddev=1.):
Generate a random TT-matrix of given shape.
After Change
raise ValueError("all elements in `tt_rank` should be integers")
if not isinstance(batch_size, (int, np.integer)):
raise ValueError("`batch_size` should be integer")
num_dims = shape.size
if tt_rank.size == 1:
tt_rank = tt_rank * np.ones(num_dims - 1)
tt_rank = np.insert(tt_rank, 0, 1)
tt_rank = np.append(tt_rank, 1)
tt_rank = tt_rank.astype(int)
cr_exponent = -1.0 / (2 * num_dims)
var = np.prod(tt_rank ** cr_exponent)
cr_stddev = stddev ** (1.0 / num_dims) * var
tt = tensor_batch_with_random_cores(shape, tt_rank=tt_rank, stddev=cr_stddev,
batch_size=batch_size)
if np.abs(mean) < 1e-8:
return tt
else:
raise NotImplementedError("non-zero mean is not supported yet")
def random_matrix(shape, tt_rank=2, mean=0., stddev=1.):
Generate a random TT-matrix of the given shape with given mean and stddev.
Entries of the generated matrix (in the full format) will be iid and satisfy
In pattern: SUPERPATTERN
Frequency: 4
Non-data size: 34
Instances
Project Name: Bihaqo/t3f
Commit Name: 29f7321b64ada5e66ff4ba8e4c9d0a44fed241f4
Time: 2018-01-04
Author: khrulkov.v@gmail.com
File Name: t3f/initializers.py
Class Name:
Method Name: random_tensor_batch
Project Name: Bihaqo/t3f
Commit Name: 29f7321b64ada5e66ff4ba8e4c9d0a44fed241f4
Time: 2018-01-04
Author: khrulkov.v@gmail.com
File Name: t3f/initializers.py
Class Name:
Method Name: random_matrix_batch
Project Name: Bihaqo/t3f
Commit Name: 29f7321b64ada5e66ff4ba8e4c9d0a44fed241f4
Time: 2018-01-04
Author: khrulkov.v@gmail.com
File Name: t3f/initializers.py
Class Name:
Method Name: random_matrix
Project Name: Bihaqo/t3f
Commit Name: 29f7321b64ada5e66ff4ba8e4c9d0a44fed241f4
Time: 2018-01-04
Author: khrulkov.v@gmail.com
File Name: t3f/initializers.py
Class Name:
Method Name: random_tensor
Project Name: Bihaqo/t3f
Commit Name: 29f7321b64ada5e66ff4ba8e4c9d0a44fed241f4
Time: 2018-01-04
Author: khrulkov.v@gmail.com
File Name: t3f/initializers.py
Class Name:
Method Name: random_tensor_batch