2018-03-29 tensorflow 使用

使用之前首先导入:

import tensorflow  as tf

几个常用的方法:

1.

https://www.tensorflow.org/versions/r1.3/api_docs/python/tf/transpose

tf.transpose

transpose(

        a,

        perm=None,

        name='transpose'

)

Args:

a:A Tensor.

perm:A permutation  of the  dimensions  of  a.

name:A  name for  operation(optional).

Returns:

A  transposed Tensor.


2.

https://www.tensorflow.org/versions/r1.2/api_docs/python/tf/reshape

tf.reshape

reshape(

         tensor,

         shape,

          name=None

)

Args:

tensor:A Tensor.

shape:A  Tensor. Must be one of the following  types: int32, int64. Defines the  shape  of  the  output  tensor.

name:A  name  for  the  operation(optional)

Returns:

A Tensor.  Has the  same  type  as  tensor.


3.

https://www.tensorflow.org/api_docs/python/tf/reduce_sum

tf.reduce_sum

tf.reduce_sum(

           input_tensor,

           axis=None,

           keepdims=None,

           name=None,

           reduction_indices=None,

           keep_dims=None

)

Args:

input_tensor: The tensor to reduce. Should have numeric type.

axis: The dimensions to reduce. If None (the default), reduces all dimensions. Must be in the range [-rank(input_tensor), rank(input_tensor)).

keepdims: If true, retains reduced dimensions with length 1.

name: A name for the operation (optional).

reduction_indices: The old (deprecated) name for axis.

keep_dims: Deprecated alias for keepdims.

Returns:

The reduced tensor.


4.

https://www.tensorflow.org/api_docs/python/tf/square

tf.square

tf.square(

        x,

        name=None

)

Args:

x: A Tensor or SparseTensor. Must be one of the following types: half, float32, float64, int32, int64, complex64, complex128.

name: A name for the operation (optional).

Returns:

A Tensor or SparseTensor. Has the same type as x.

5.

https://www.tensorflow.org/api_docs/python/tf/subtract

tf.subtract

tf.subtract(

         x,

         y,

         name=None

)

Args:

x: A Tensor. Must be one of the following types: half, bfloat16, float32, float64, uint8, int8, uint16, int16, int32, int64, complex64, complex128.

y: A Tensor. Must have the same type as x.

name: A name for the operation (optional).

Returns:

A Tensor. Has the same type as x.

Returns x - y element-wise.

你可能感兴趣的:(2018-03-29 tensorflow 使用)