Skip to content

Commit 2cd0810

Browse files
taehoonleermlarsen
authored andcommitted
Increase docstring consistency (tensorflow#11932)
* Increase docstring consistency * Update util.py * Update tensor_shape.py These comparison examples need parenthesis to work properly. * Update math_ops.py Set values to `start`, `limit`, and `delta`
1 parent 89d4908 commit 2cd0810

15 files changed

Lines changed: 376 additions & 401 deletions

File tree

tensorflow/contrib/batching/python/ops/batch_ops.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def batch_function(num_batch_threads, max_batch_size, batch_timeout_micros,
6767
6868
So, for example, in the following code
6969
70-
```
70+
```python
7171
@batch_function(1, 2, 3)
7272
def layer(a):
7373
return tf.matmul(a, a)

tensorflow/contrib/layers/python/layers/layers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1944,7 +1944,7 @@ def gdn(inputs,
19441944
spatial dimensions. It is similar to local response normalization, but much
19451945
more flexible, as `beta` and `gamma` are trainable parameters.
19461946
1947-
Arguments:
1947+
Args:
19481948
inputs: Tensor input.
19491949
inverse: If `False` (default), compute GDN response. If `True`, compute IGDN
19501950
response (one step of fixed point iteration to invert GDN; the division

tensorflow/python/feature_column/feature_column.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1468,11 +1468,11 @@ class _LazyBuilder(object):
14681468
We're trying to use the following `_FeatureColumn`s:
14691469
14701470
```python
1471-
bucketized_age = fc.bucketized_column(fc.numeric_column("age"), ...)
1472-
keywords = fc.categorical_column_with_hash_buckets("keywords", ...)
1473-
age_X_keywords = fc.crossed_column([bucketized_age, "keywords"])
1474-
... = linear_model(features,
1475-
[bucketized_age, keywords, age_X_keywords]
1471+
bucketized_age = fc.bucketized_column(fc.numeric_column("age"), ...)
1472+
keywords = fc.categorical_column_with_hash_buckets("keywords", ...)
1473+
age_X_keywords = fc.crossed_column([bucketized_age, "keywords"])
1474+
... = linear_model(features,
1475+
[bucketized_age, keywords, age_X_keywords]
14761476
```
14771477
14781478
If we transform each column independently, then we'll get duplication of

tensorflow/python/framework/ops.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1238,7 +1238,7 @@ def __init__(self, node_def, g, inputs=None, output_types=None,
12381238
def _create_c_op(self, graph, node_def, inputs, control_inputs):
12391239
"""Creates a TF_Operation.
12401240
1241-
Arguments:
1241+
Args:
12421242
graph: a `Graph`.
12431243
node_def: `node_def_pb2.NodeDef` for the operation to create.
12441244
inputs: A list of `Tensor`s (corresponding to scalar inputs) and lists of
@@ -1282,7 +1282,7 @@ def _create_c_op(self, graph, node_def, inputs, control_inputs):
12821282
def _reconstruct_sequence_inputs(self, op_def, inputs, attrs):
12831283
"""Regroups a flat list of input tensors into scalar and sequence inputs.
12841284
1285-
Arguments:
1285+
Args:
12861286
op_def: The `op_def_pb2.OpDef` (for knowing the input types)
12871287
inputs: a list of input `Tensor`s to the op.
12881288
attrs: mapping from attr name to `attr_value_pb2.AttrValue` (these define

tensorflow/python/framework/tensor_shape.py

Lines changed: 59 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,11 @@ def merge_with(self, other):
116116
Dimensions are combined as follows:
117117
118118
```python
119-
Dimension(n) .merge_with(Dimension(n)) == Dimension(n)
120-
Dimension(n) .merge_with(Dimension(None)) == Dimension(n)
121-
Dimension(None).merge_with(Dimension(n)) == Dimension(n)
122-
Dimension(None).merge_with(Dimension(None)) == Dimension(None)
123-
Dimension(n) .merge_with(Dimension(m)) raises ValueError for n != m
119+
tf.Dimension(n) .merge_with(tf.Dimension(n)) == tf.Dimension(n)
120+
tf.Dimension(n) .merge_with(tf.Dimension(None)) == tf.Dimension(n)
121+
tf.Dimension(None).merge_with(tf.Dimension(n)) == tf.Dimension(n)
122+
tf.Dimension(None).merge_with(tf.Dimension(None)) == tf.Dimension(None)
123+
tf.Dimension(n) .merge_with(tf.Dimension(m)) # raises ValueError for n != m
124124
```
125125
126126
Args:
@@ -146,10 +146,12 @@ def __add__(self, other):
146146
147147
Dimensions are summed as follows:
148148
149-
Dimension(m) + Dimension(n) == Dimension(m + n)
150-
Dimension(m) + Dimension(None) == Dimension(None)
151-
Dimension(None) + Dimension(n) == Dimension(None)
152-
Dimension(None) + Dimension(None) == Dimension(None)
149+
```python
150+
tf.Dimension(m) + tf.Dimension(n) == tf.Dimension(m + n)
151+
tf.Dimension(m) + tf.Dimension(None) == tf.Dimension(None)
152+
tf.Dimension(None) + tf.Dimension(n) == tf.Dimension(None)
153+
tf.Dimension(None) + tf.Dimension(None) == tf.Dimension(None)
154+
```
153155
154156
Args:
155157
other: Another Dimension.
@@ -168,10 +170,12 @@ def __sub__(self, other):
168170
169171
Dimensions are subtracted as follows:
170172
171-
Dimension(m) - Dimension(n) == Dimension(m - n)
172-
Dimension(m) - Dimension(None) == Dimension(None)
173-
Dimension(None) - Dimension(n) == Dimension(None)
174-
Dimension(None) - Dimension(None) == Dimension(None)
173+
```python
174+
tf.Dimension(m) - tf.Dimension(n) == tf.Dimension(m - n)
175+
tf.Dimension(m) - tf.Dimension(None) == tf.Dimension(None)
176+
tf.Dimension(None) - tf.Dimension(n) == tf.Dimension(None)
177+
tf.Dimension(None) - tf.Dimension(None) == tf.Dimension(None)
178+
```
175179
176180
Args:
177181
other: Another Dimension.
@@ -190,11 +194,11 @@ def __mul__(self, other):
190194
191195
Dimensions are summed as follows:
192196
193-
```
194-
Dimension(m) * Dimension(n) == Dimension(m * n)
195-
Dimension(m) * Dimension(None) == Dimension(None)
196-
Dimension(None) * Dimension(n) == Dimension(None)
197-
Dimension(None) * Dimension(None) == Dimension(None)
197+
```python
198+
tf.Dimension(m) * tf.Dimension(n) == tf.Dimension(m * n)
199+
tf.Dimension(m) * tf.Dimension(None) == tf.Dimension(None)
200+
tf.Dimension(None) * tf.Dimension(n) == tf.Dimension(None)
201+
tf.Dimension(None) * tf.Dimension(None) == tf.Dimension(None)
198202
```
199203
200204
Args:
@@ -214,10 +218,12 @@ def __floordiv__(self, other):
214218
215219
Dimensions are divided as follows:
216220
217-
Dimension(m) // Dimension(n) == Dimension(m // n)
218-
Dimension(m) // Dimension(None) == Dimension(None)
219-
Dimension(None) // Dimension(n) == Dimension(None)
220-
Dimension(None) // Dimension(None) == Dimension(None)
221+
```python
222+
tf.Dimension(m) // tf.Dimension(n) == tf.Dimension(m // n)
223+
tf.Dimension(m) // tf.Dimension(None) == tf.Dimension(None)
224+
tf.Dimension(None) // tf.Dimension(n) == tf.Dimension(None)
225+
tf.Dimension(None) // tf.Dimension(None) == tf.Dimension(None)
226+
```
221227
222228
Args:
223229
other: Another `Dimension`.
@@ -250,12 +256,14 @@ def __div__(self, other):
250256
def __mod__(self, other):
251257
"""Returns `self` modulo `other.
252258
253-
Dimension moduli are computed as follows:
259+
Dimension moduli are computed as follows:
254260
255-
Dimension(m) % Dimension(n) == Dimension(m % n)
256-
Dimension(m) % Dimension(None) == Dimension(None)
257-
Dimension(None) % Dimension(n) == Dimension(None)
258-
Dimension(None) % Dimension(None) == Dimension(None)
261+
```python
262+
tf.Dimension(m) % tf.Dimension(n) == tf.Dimension(m % n)
263+
tf.Dimension(m) % tf.Dimension(None) == tf.Dimension(None)
264+
tf.Dimension(None) % tf.Dimension(n) == tf.Dimension(None)
265+
tf.Dimension(None) % tf.Dimension(None) == tf.Dimension(None)
266+
```
259267
260268
Args:
261269
other: Another Dimension.
@@ -274,10 +282,12 @@ def __lt__(self, other):
274282
275283
Dimensions are compared as follows:
276284
277-
Dimension(m) < Dimension(n) == m < n
278-
Dimension(m) < Dimension(None) == None
279-
Dimension(None) < Dimension(n) == None
280-
Dimension(None) < Dimension(None) == None
285+
```python
286+
(tf.Dimension(m) < tf.Dimension(n)) == (m < n)
287+
(tf.Dimension(m) < tf.Dimension(None)) == None
288+
(tf.Dimension(None) < tf.Dimension(n)) == None
289+
(tf.Dimension(None) < tf.Dimension(None)) == None
290+
```
281291
282292
Args:
283293
other: Another Dimension.
@@ -297,10 +307,12 @@ def __le__(self, other):
297307
298308
Dimensions are compared as follows:
299309
300-
Dimension(m) <= Dimension(n) == m <= n
301-
Dimension(m) <= Dimension(None) == None
302-
Dimension(None) <= Dimension(n) == None
303-
Dimension(None) <= Dimension(None) == None
310+
```python
311+
(tf.Dimension(m) <= tf.Dimension(n)) == (m <= n)
312+
(tf.Dimension(m) <= tf.Dimension(None)) == None
313+
(tf.Dimension(None) <= tf.Dimension(n)) == None
314+
(tf.Dimension(None) <= tf.Dimension(None)) == None
315+
```
304316
305317
Args:
306318
other: Another Dimension.
@@ -320,10 +332,12 @@ def __gt__(self, other):
320332
321333
Dimensions are compared as follows:
322334
323-
Dimension(m) > Dimension(n) == m > n
324-
Dimension(m) > Dimension(None) == None
325-
Dimension(None) > Dimension(n) == None
326-
Dimension(None) > Dimension(None) == None
335+
```python
336+
(tf.Dimension(m) > tf.Dimension(n)) == (m > n)
337+
(tf.Dimension(m) > tf.Dimension(None)) == None
338+
(tf.Dimension(None) > tf.Dimension(n)) == None
339+
(tf.Dimension(None) > tf.Dimension(None)) == None
340+
```
327341
328342
Args:
329343
other: Another Dimension.
@@ -343,10 +357,12 @@ def __ge__(self, other):
343357
344358
Dimensions are compared as follows:
345359
346-
Dimension(m) >= Dimension(n) == m >= n
347-
Dimension(m) >= Dimension(None) == None
348-
Dimension(None) >= Dimension(n) == None
349-
Dimension(None) >= Dimension(None) == None
360+
```python
361+
(tf.Dimension(m) >= tf.Dimension(n)) == (m >= n)
362+
(tf.Dimension(m) >= tf.Dimension(None)) == None
363+
(tf.Dimension(None) >= tf.Dimension(n)) == None
364+
(tf.Dimension(None) >= tf.Dimension(None)) == None
365+
```
350366
351367
Args:
352368
other: Another Dimension.

tensorflow/python/layers/base.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2079,11 +2079,9 @@ def _unique_layer_name(name):
20792079
20802080
Example:
20812081
2082-
```
2083-
>>> _unique_layer_name('dense')
2084-
dense_1
2085-
>>> _unique_layer_name('dense')
2086-
dense_2
2082+
```python
2083+
_unique_layer_name('dense') # dense_1
2084+
_unique_layer_name('dense') # dense_2
20872085
```
20882086
"""
20892087
graph = ops.get_default_graph()

0 commit comments

Comments
 (0)