MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / _get_sharded_variable

Function _get_sharded_variable

tensorflow/contrib/rnn/python/ops/rnn_cell.py:67–83  ·  view source on GitHub ↗

Get a list of sharded variables with the given dtype.

(name, shape, dtype, num_shards)

Source from the content-addressed store, hash-verified

65
66
67def _get_sharded_variable(name, shape, dtype, num_shards):
68 """Get a list of sharded variables with the given dtype."""
69 if num_shards > shape[0]:
70 raise ValueError("Too many shards: shape=%s, num_shards=%d" % (shape,
71 num_shards))
72 unit_shard_size = int(math.floor(shape[0] / num_shards))
73 remaining_rows = shape[0] - unit_shard_size * num_shards
74
75 shards = []
76 for i in range(num_shards):
77 current_size = unit_shard_size
78 if i < remaining_rows:
79 current_size += 1
80 shards.append(
81 vs.get_variable(
82 name + "_%d" % i, [current_size] + shape[1:], dtype=dtype))
83 return shards
84
85
86def _norm(g, b, inp, scope):

Callers 1

_get_concat_variableFunction · 0.85

Calls 3

rangeFunction · 0.50
appendMethod · 0.45
get_variableMethod · 0.45

Tested by

no test coverage detected