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

Function fill

tensorflow/python/ops/array_ops.py:137–173  ·  view source on GitHub ↗

r"""Creates a tensor filled with a scalar value. This operation creates a tensor of shape `dims` and fills it with `value`. For example: ``` # Output tensor has shape [2, 3]. fill([2, 3], 9) ==> [[9, 9, 9] [9, 9, 9]] ``` `tf.fill` differs from `tf.constant` i

(dims, value, name=None)

Source from the content-addressed store, hash-verified

135
136@tf_export("fill")
137def fill(dims, value, name=None):
138 r"""Creates a tensor filled with a scalar value.
139
140 This operation creates a tensor of shape `dims` and fills it with `value`.
141
142 For example:
143
144 ```
145 # Output tensor has shape [2, 3].
146 fill([2, 3], 9) ==> [[9, 9, 9]
147 [9, 9, 9]]
148 ```
149
150 `tf.fill` differs from `tf.constant` in a few ways:
151
152 * `tf.fill` only supports scalar contents, whereas `tf.constant` supports
153 Tensor values.
154 * `tf.fill` creates an Op in the computation graph that constructs the
155 actual
156 Tensor value at runtime. This is in contrast to `tf.constant` which embeds
157 the entire Tensor into the graph with a `Const` node.
158 * Because `tf.fill` evaluates at graph runtime, it supports dynamic shapes
159 based on other runtime Tensors, unlike `tf.constant`.
160
161 Args:
162 dims: A `Tensor`. Must be one of the following types: `int32`, `int64`. 1-D.
163 Represents the shape of the output tensor.
164 value: A `Tensor`. 0-D (scalar). Value to fill the returned tensor.
165 @compatibility(numpy) Equivalent to np.full @end_compatibility
166 name: A name for the operation (optional).
167
168 Returns:
169 A `Tensor`. Has the same type as `value`.
170 """
171 result = gen_array_ops.fill(dims, value, name=name)
172 tensor_util.maybe_set_static_shape(result, dims)
173 return result
174
175
176@tf_export("identity")

Callers 15

zerosFunction · 0.70
onesFunction · 0.70
InitializeFunction · 0.50
UpdatePartitionsMethod · 0.50
PartitionExamplesMethod · 0.50
TESTFunction · 0.50
EvalFunction · 0.50
TESTFunction · 0.50
FillMethod · 0.50
BumpIndicesMethod · 0.50

Calls 1

fillMethod · 0.80

Tested by 8

TESTFunction · 0.40
TESTFunction · 0.40
XLA_TEST_FFunction · 0.40
AddExampleMethod · 0.40
SampleFunction · 0.40
BytesPerElementHelperFunction · 0.40