Compare commits

...

5 Commits

Author SHA1 Message Date
Shanqing Cai
b5e5120c58 Merge pull request #7828 from tensorflow/skleinfeld-patch-2
Adding missing close parenthesis in code listing.
2017-03-03 04:35:25 +00:00
Sanders Kleinfeld
87dfdc5180 Adding missing close parenthesis in code listing. 2017-02-23 15:54:29 -05:00
Justine Tunney
45ab528211 Fix nasm URL (#6963)
See #6956
2017-01-20 13:09:16 -08:00
gunan
787cd3de6a Fix expand_dim docs. (#6753)
* Fixed expand_dims docstring.
Change: 139828406

* Fix docs for tf.expand_dims.
2017-01-09 18:43:34 -08:00
Vijay Vasudevan
1e317b1f7d Update zlib url in r0.12 branch (#6658)
(Similar to change done to master, to make r0.12 buildable).
2017-01-04 22:59:07 -08:00
5 changed files with 102 additions and 48 deletions

View File

@ -476,53 +476,57 @@ shape(squeeze(t, [2, 4])) ==> [1, 2, 3, 1]
### `tf.expand_dims(input, axis=None, name=None, dim=None)` {#expand_dims}
Inserts a axisension of 1 into a tensor's shape.
Inserts a dimension of 1 into a tensor's shape.
Given a tensor `input`, this operation inserts a axisension of 1 at the
axisension index `axis` of `input`'s shape. The axisension index `axis` starts at
zero; if you specify a negative number for `axis` it is counted backward from
the end.
Given a tensor `input`, this operation inserts a dimension of 1 at the
dimension index `axis` of `input`'s shape. The dimension index `axis` starts
at zero; if you specify a negative number for `axis` it is counted backward
from the end.
This operation is useful if you want to add a batch axisension to a single
This operation is useful if you want to add a batch dimension to a single
element. For example, if you have a single image of shape `[height, width,
channels]`, you can make it a batch of 1 image with `expand_axiss(image, 0)`,
channels]`, you can make it a batch of 1 image with `expand_dims(image, 0)`,
which will make the shape `[1, height, width, channels]`.
Other examples:
```prettyprint
```python
# 't' is a tensor of shape [2]
shape(expand_axiss(t, 0)) ==> [1, 2]
shape(expand_axiss(t, 1)) ==> [2, 1]
shape(expand_axiss(t, -1)) ==> [2, 1]
shape(expand_dims(t, 0)) ==> [1, 2]
shape(expand_dims(t, 1)) ==> [2, 1]
shape(expand_dims(t, -1)) ==> [2, 1]
# 't2' is a tensor of shape [2, 3, 5]
shape(expand_axiss(t2, 0)) ==> [1, 2, 3, 5]
shape(expand_axiss(t2, 2)) ==> [2, 3, 1, 5]
shape(expand_axiss(t2, 3)) ==> [2, 3, 5, 1]
shape(expand_dims(t2, 0)) ==> [1, 2, 3, 5]
shape(expand_dims(t2, 2)) ==> [2, 3, 1, 5]
shape(expand_dims(t2, 3)) ==> [2, 3, 5, 1]
```
This operation requires that:
`-1-input.axiss() <= axis <= input.axiss()`
`-1-input.dims() <= dim <= input.dims()`
This operation is related to `squeeze()`, which removes axisensions of
This operation is related to `squeeze()`, which removes dimensions of
size 1.
##### Args:
* <b>`input`</b>: A `Tensor`.
* <b>`axis`</b>: A `Tensor`. Must be one of the following types: `int32`, `int64`.
0-D (scalar). Specifies the axisension index at which to
* <b>`axis`</b>: 0-D (scalar). Specifies the dimension index at which to
expand the shape of `input`.
* <b>`name`</b>: A name for the operation (optional).
* <b>`name`</b>: The name of the output `Tensor`.
* <b>`dim`</b>: 0-D (scalar). Equivalent to `axis`, to be deprecated.
##### Returns:
A `Tensor`. Has the same type as `input`.
Contains the same data as `input`, but its shape has an additional
axisension of size 1 added.
A `Tensor` with the same data as `input`, but its shape has an additional
dimension of size 1 added.
##### Raises:
* <b>`ValueError`</b>: if both `dim` and `axis` are specified.
- - -

View File

@ -1,50 +1,54 @@
### `tf.expand_dims(input, axis=None, name=None, dim=None)` {#expand_dims}
Inserts a axisension of 1 into a tensor's shape.
Inserts a dimension of 1 into a tensor's shape.
Given a tensor `input`, this operation inserts a axisension of 1 at the
axisension index `axis` of `input`'s shape. The axisension index `axis` starts at
zero; if you specify a negative number for `axis` it is counted backward from
the end.
Given a tensor `input`, this operation inserts a dimension of 1 at the
dimension index `axis` of `input`'s shape. The dimension index `axis` starts
at zero; if you specify a negative number for `axis` it is counted backward
from the end.
This operation is useful if you want to add a batch axisension to a single
This operation is useful if you want to add a batch dimension to a single
element. For example, if you have a single image of shape `[height, width,
channels]`, you can make it a batch of 1 image with `expand_axiss(image, 0)`,
channels]`, you can make it a batch of 1 image with `expand_dims(image, 0)`,
which will make the shape `[1, height, width, channels]`.
Other examples:
```prettyprint
```python
# 't' is a tensor of shape [2]
shape(expand_axiss(t, 0)) ==> [1, 2]
shape(expand_axiss(t, 1)) ==> [2, 1]
shape(expand_axiss(t, -1)) ==> [2, 1]
shape(expand_dims(t, 0)) ==> [1, 2]
shape(expand_dims(t, 1)) ==> [2, 1]
shape(expand_dims(t, -1)) ==> [2, 1]
# 't2' is a tensor of shape [2, 3, 5]
shape(expand_axiss(t2, 0)) ==> [1, 2, 3, 5]
shape(expand_axiss(t2, 2)) ==> [2, 3, 1, 5]
shape(expand_axiss(t2, 3)) ==> [2, 3, 5, 1]
shape(expand_dims(t2, 0)) ==> [1, 2, 3, 5]
shape(expand_dims(t2, 2)) ==> [2, 3, 1, 5]
shape(expand_dims(t2, 3)) ==> [2, 3, 5, 1]
```
This operation requires that:
`-1-input.axiss() <= axis <= input.axiss()`
`-1-input.dims() <= dim <= input.dims()`
This operation is related to `squeeze()`, which removes axisensions of
This operation is related to `squeeze()`, which removes dimensions of
size 1.
##### Args:
* <b>`input`</b>: A `Tensor`.
* <b>`axis`</b>: A `Tensor`. Must be one of the following types: `int32`, `int64`.
0-D (scalar). Specifies the axisension index at which to
* <b>`axis`</b>: 0-D (scalar). Specifies the dimension index at which to
expand the shape of `input`.
* <b>`name`</b>: A name for the operation (optional).
* <b>`name`</b>: The name of the output `Tensor`.
* <b>`dim`</b>: 0-D (scalar). Equivalent to `axis`, to be deprecated.
##### Returns:
A `Tensor`. Has the same type as `input`.
Contains the same data as `input`, but its shape has an additional
axisension of size 1 added.
A `Tensor` with the same data as `input`, but its shape has an additional
dimension of size 1 added.
##### Raises:
* <b>`ValueError`</b>: if both `dim` and `axis` are specified.

View File

@ -286,7 +286,7 @@ accept a _pandas_ `Dataframe` and return feature column and label values as
```python
def input_fn(data_set):
feature_cols = {k: tf.constant(data_set[k].values
feature_cols = {k: tf.constant(data_set[k].values)
for k in FEATURES}
labels = tf.constant(data_set[LABEL].values)
return feature_cols, labels

View File

@ -130,13 +130,59 @@ _baseslice = slice
# pylint: disable=redefined-builtin,protected-access
def expand_dims(input, axis=None, name=None, dim=None):
"""Inserts a dimension of 1 into a tensor's shape.
Given a tensor `input`, this operation inserts a dimension of 1 at the
dimension index `axis` of `input`'s shape. The dimension index `axis` starts
at zero; if you specify a negative number for `axis` it is counted backward
from the end.
This operation is useful if you want to add a batch dimension to a single
element. For example, if you have a single image of shape `[height, width,
channels]`, you can make it a batch of 1 image with `expand_dims(image, 0)`,
which will make the shape `[1, height, width, channels]`.
Other examples:
```python
# 't' is a tensor of shape [2]
shape(expand_dims(t, 0)) ==> [1, 2]
shape(expand_dims(t, 1)) ==> [2, 1]
shape(expand_dims(t, -1)) ==> [2, 1]
# 't2' is a tensor of shape [2, 3, 5]
shape(expand_dims(t2, 0)) ==> [1, 2, 3, 5]
shape(expand_dims(t2, 2)) ==> [2, 3, 1, 5]
shape(expand_dims(t2, 3)) ==> [2, 3, 5, 1]
```
This operation requires that:
`-1-input.dims() <= dim <= input.dims()`
This operation is related to `squeeze()`, which removes dimensions of
size 1.
Args:
input: A `Tensor`.
axis: 0-D (scalar). Specifies the dimension index at which to
expand the shape of `input`.
name: The name of the output `Tensor`.
dim: 0-D (scalar). Equivalent to `axis`, to be deprecated.
Returns:
A `Tensor` with the same data as `input`, but its shape has an additional
dimension of size 1 added.
Raises:
ValueError: if both `dim` and `axis` are specified.
"""
# TODO(aselle): Remove argument dim
if dim is not None:
if axis is not None:
raise ValueError("can't specify both 'dim' and 'axis'")
axis = dim
return gen_array_ops._expand_dims(input, axis, name)
expand_dims.__doc__ = gen_array_ops._expand_dims.__doc__.replace("dim", "axis")
# pylint: enable=redefined-builtin,protected-access

View File

@ -64,7 +64,7 @@ def tf_workspace(path_prefix = "", tf_repo_name = ""):
native.new_http_archive(
name = "nasm",
url = "http://www.nasm.us/pub/nasm/releasebuilds/2.12.02/nasm-2.12.02.tar.bz2",
url = "http://pkgs.fedoraproject.org/repo/pkgs/nasm/nasm-2.12.02.tar.bz2/d15843c3fb7db39af80571ee27ec6fad/nasm-2.12.02.tar.bz2",
sha256 = "00b0891c678c065446ca59bcee64719d0096d54d6886e6e472aeee2e170ae324",
strip_prefix = "nasm-2.12.02",
build_file = str(Label("//third_party:nasm.BUILD")),
@ -228,7 +228,7 @@ def tf_workspace(path_prefix = "", tf_repo_name = ""):
native.new_http_archive(
name = "zlib_archive",
url = "http://zlib.net/zlib-1.2.8.tar.gz",
url = "http://zlib.net/fossils/zlib-1.2.8.tar.gz",
sha256 = "36658cb768a54c1d4dec43c3116c27ed893e88b02ecfcb44f2166f9c0b7f2a0d",
strip_prefix = "zlib-1.2.8",
build_file = str(Label("//:zlib.BUILD")),