Compare commits
5 Commits
rei/fork-r
...
r0.12
Author | SHA1 | Date | |
---|---|---|---|
|
b5e5120c58 | ||
|
87dfdc5180 | ||
|
45ab528211 | ||
|
787cd3de6a | ||
|
1e317b1f7d |
@ -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}
|
### `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
|
Given a tensor `input`, this operation inserts a dimension of 1 at the
|
||||||
axisension index `axis` of `input`'s shape. The axisension index `axis` starts at
|
dimension index `axis` of `input`'s shape. The dimension index `axis` starts
|
||||||
zero; if you specify a negative number for `axis` it is counted backward from
|
at zero; if you specify a negative number for `axis` it is counted backward
|
||||||
the end.
|
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,
|
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]`.
|
which will make the shape `[1, height, width, channels]`.
|
||||||
|
|
||||||
Other examples:
|
Other examples:
|
||||||
|
|
||||||
```prettyprint
|
```python
|
||||||
# 't' is a tensor of shape [2]
|
# 't' is a tensor of shape [2]
|
||||||
shape(expand_axiss(t, 0)) ==> [1, 2]
|
shape(expand_dims(t, 0)) ==> [1, 2]
|
||||||
shape(expand_axiss(t, 1)) ==> [2, 1]
|
shape(expand_dims(t, 1)) ==> [2, 1]
|
||||||
shape(expand_axiss(t, -1)) ==> [2, 1]
|
shape(expand_dims(t, -1)) ==> [2, 1]
|
||||||
|
|
||||||
# 't2' is a tensor of shape [2, 3, 5]
|
# 't2' is a tensor of shape [2, 3, 5]
|
||||||
shape(expand_axiss(t2, 0)) ==> [1, 2, 3, 5]
|
shape(expand_dims(t2, 0)) ==> [1, 2, 3, 5]
|
||||||
shape(expand_axiss(t2, 2)) ==> [2, 3, 1, 5]
|
shape(expand_dims(t2, 2)) ==> [2, 3, 1, 5]
|
||||||
shape(expand_axiss(t2, 3)) ==> [2, 3, 5, 1]
|
shape(expand_dims(t2, 3)) ==> [2, 3, 5, 1]
|
||||||
```
|
```
|
||||||
|
|
||||||
This operation requires that:
|
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.
|
size 1.
|
||||||
|
|
||||||
##### Args:
|
##### Args:
|
||||||
|
|
||||||
|
|
||||||
* <b>`input`</b>: A `Tensor`.
|
* <b>`input`</b>: A `Tensor`.
|
||||||
* <b>`axis`</b>: A `Tensor`. Must be one of the following types: `int32`, `int64`.
|
* <b>`axis`</b>: 0-D (scalar). Specifies the dimension index at which to
|
||||||
0-D (scalar). Specifies the axisension index at which to
|
|
||||||
expand the shape of `input`.
|
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:
|
##### Returns:
|
||||||
|
|
||||||
A `Tensor`. Has the same type as `input`.
|
A `Tensor` with the same data as `input`, but its shape has an additional
|
||||||
Contains the same data as `input`, but its shape has an additional
|
dimension of size 1 added.
|
||||||
axisension of size 1 added.
|
|
||||||
|
##### Raises:
|
||||||
|
|
||||||
|
|
||||||
|
* <b>`ValueError`</b>: if both `dim` and `axis` are specified.
|
||||||
|
|
||||||
|
|
||||||
- - -
|
- - -
|
||||||
|
@ -1,50 +1,54 @@
|
|||||||
### `tf.expand_dims(input, axis=None, name=None, dim=None)` {#expand_dims}
|
### `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
|
Given a tensor `input`, this operation inserts a dimension of 1 at the
|
||||||
axisension index `axis` of `input`'s shape. The axisension index `axis` starts at
|
dimension index `axis` of `input`'s shape. The dimension index `axis` starts
|
||||||
zero; if you specify a negative number for `axis` it is counted backward from
|
at zero; if you specify a negative number for `axis` it is counted backward
|
||||||
the end.
|
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,
|
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]`.
|
which will make the shape `[1, height, width, channels]`.
|
||||||
|
|
||||||
Other examples:
|
Other examples:
|
||||||
|
|
||||||
```prettyprint
|
```python
|
||||||
# 't' is a tensor of shape [2]
|
# 't' is a tensor of shape [2]
|
||||||
shape(expand_axiss(t, 0)) ==> [1, 2]
|
shape(expand_dims(t, 0)) ==> [1, 2]
|
||||||
shape(expand_axiss(t, 1)) ==> [2, 1]
|
shape(expand_dims(t, 1)) ==> [2, 1]
|
||||||
shape(expand_axiss(t, -1)) ==> [2, 1]
|
shape(expand_dims(t, -1)) ==> [2, 1]
|
||||||
|
|
||||||
# 't2' is a tensor of shape [2, 3, 5]
|
# 't2' is a tensor of shape [2, 3, 5]
|
||||||
shape(expand_axiss(t2, 0)) ==> [1, 2, 3, 5]
|
shape(expand_dims(t2, 0)) ==> [1, 2, 3, 5]
|
||||||
shape(expand_axiss(t2, 2)) ==> [2, 3, 1, 5]
|
shape(expand_dims(t2, 2)) ==> [2, 3, 1, 5]
|
||||||
shape(expand_axiss(t2, 3)) ==> [2, 3, 5, 1]
|
shape(expand_dims(t2, 3)) ==> [2, 3, 5, 1]
|
||||||
```
|
```
|
||||||
|
|
||||||
This operation requires that:
|
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.
|
size 1.
|
||||||
|
|
||||||
##### Args:
|
##### Args:
|
||||||
|
|
||||||
|
|
||||||
* <b>`input`</b>: A `Tensor`.
|
* <b>`input`</b>: A `Tensor`.
|
||||||
* <b>`axis`</b>: A `Tensor`. Must be one of the following types: `int32`, `int64`.
|
* <b>`axis`</b>: 0-D (scalar). Specifies the dimension index at which to
|
||||||
0-D (scalar). Specifies the axisension index at which to
|
|
||||||
expand the shape of `input`.
|
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:
|
##### Returns:
|
||||||
|
|
||||||
A `Tensor`. Has the same type as `input`.
|
A `Tensor` with the same data as `input`, but its shape has an additional
|
||||||
Contains the same data as `input`, but its shape has an additional
|
dimension of size 1 added.
|
||||||
axisension of size 1 added.
|
|
||||||
|
##### Raises:
|
||||||
|
|
||||||
|
|
||||||
|
* <b>`ValueError`</b>: if both `dim` and `axis` are specified.
|
||||||
|
|
||||||
|
@ -286,7 +286,7 @@ accept a _pandas_ `Dataframe` and return feature column and label values as
|
|||||||
|
|
||||||
```python
|
```python
|
||||||
def input_fn(data_set):
|
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}
|
for k in FEATURES}
|
||||||
labels = tf.constant(data_set[LABEL].values)
|
labels = tf.constant(data_set[LABEL].values)
|
||||||
return feature_cols, labels
|
return feature_cols, labels
|
||||||
|
@ -130,13 +130,59 @@ _baseslice = slice
|
|||||||
|
|
||||||
# pylint: disable=redefined-builtin,protected-access
|
# pylint: disable=redefined-builtin,protected-access
|
||||||
def expand_dims(input, axis=None, name=None, dim=None):
|
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
|
# TODO(aselle): Remove argument dim
|
||||||
if dim is not None:
|
if dim is not None:
|
||||||
if axis is not None:
|
if axis is not None:
|
||||||
raise ValueError("can't specify both 'dim' and 'axis'")
|
raise ValueError("can't specify both 'dim' and 'axis'")
|
||||||
axis = dim
|
axis = dim
|
||||||
return gen_array_ops._expand_dims(input, axis, name)
|
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
|
# pylint: enable=redefined-builtin,protected-access
|
||||||
|
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ def tf_workspace(path_prefix = "", tf_repo_name = ""):
|
|||||||
|
|
||||||
native.new_http_archive(
|
native.new_http_archive(
|
||||||
name = "nasm",
|
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",
|
sha256 = "00b0891c678c065446ca59bcee64719d0096d54d6886e6e472aeee2e170ae324",
|
||||||
strip_prefix = "nasm-2.12.02",
|
strip_prefix = "nasm-2.12.02",
|
||||||
build_file = str(Label("//third_party:nasm.BUILD")),
|
build_file = str(Label("//third_party:nasm.BUILD")),
|
||||||
@ -228,7 +228,7 @@ def tf_workspace(path_prefix = "", tf_repo_name = ""):
|
|||||||
|
|
||||||
native.new_http_archive(
|
native.new_http_archive(
|
||||||
name = "zlib_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",
|
sha256 = "36658cb768a54c1d4dec43c3116c27ed893e88b02ecfcb44f2166f9c0b7f2a0d",
|
||||||
strip_prefix = "zlib-1.2.8",
|
strip_prefix = "zlib-1.2.8",
|
||||||
build_file = str(Label("//:zlib.BUILD")),
|
build_file = str(Label("//:zlib.BUILD")),
|
||||||
|
Loading…
Reference in New Issue
Block a user