tensorflow函式集
阿新 • • 發佈:2018-12-04
本文轉自:https://blog.csdn.net/Yshihui/article/details/80539982
中文解釋:https://wenku.baidu.com/view/34fb1cae50e79b89680203d8ce2f0066f5336495.html
在工程應用中,直接ctrl+f查詢所用函式解釋
Neural Network
- Activation Functions
- Convolution
- Pooling
- Normalization
- Losses
- Classification
- Embeddings
- Evaluation
- Candidate Sampling
- Sampled Loss Functions
tf.nn.nce_loss(weights, biases, inputs, labels, num_sampled, num_classes, num_true=1, sampled_values=None, remove_accidental_hits=False, name='nce_loss')
tf.nn.sampled_softmax_loss(weights, biases, inputs, labels, num_sampled, num_classes, num_true=1, sampled_values=None, remove_accidental_hits=True, name='sampled_softmax_loss')
- Candidate Samplers
tf.nn.uniform_candidate_sampler(true_classes, num_true, num_sampled, unique, range_max, seed=None, name=None)
tf.nn.log_uniform_candidate_sampler(true_classes, num_true, num_sampled, unique, range_max, seed=None, name=None)
tf.nn.learned_unigram_candidate_sampler(true_classes, num_true, num_sampled, unique, range_max, seed=None, name=None)
tf.nn.fixed_unigram_candidate_sampler(true_classes, num_true, num_sampled, unique, range_max, vocab_file='', distortion=0.0, num_reserved_ids=0, num_shards=1, shard=0, unigrams=[], seed=None, name=None)
- Miscellaneous candidate sampling utilities
tf.nn.compute_accidental_hits(true_classes, sampled_candidates, num_true, seed=None, name=None)
Math
- Arithmetic Operators
- Basic Math Functions
tf.add_n(inputs, name=None)
tf.abs(x, name=None)
tf.neg(x, name=None)
tf.sign(x, name=None)
tf.inv(x, name=None)
tf.square(x, name=None)
tf.round(x, name=None)
tf.sqrt(x, name=None)
tf.rsqrt(x, name=None)
tf.pow(x, y, name=None)
tf.exp(x, name=None)
tf.log(x, name=None)
tf.ceil(x, name=None)
tf.floor(x, name=None)
tf.maximum(x, y, name=None)
tf.minimum(x, y, name=None)
tf.cos(x, name=None)
tf.sin(x, name=None)
- Matrix Math Functions
tf.diag(diagonal, name=None)
tf.transpose(a, perm=None, name='transpose')
tf.matmul(a, b, transpose_a=False, transpose_b=False, a_is_sparse=False, b_is_sparse=False, name=None)
tf.batch_matmul(x, y, adj_x=None, adj_y=None, name=None)
tf.matrix_determinant(input, name=None)
tf.batch_matrix_determinant(input, name=None)
tf.matrix_inverse(input, name=None)
tf.batch_matrix_inverse(input, name=None)
tf.cholesky(input, name=None)
tf.batch_cholesky(input, name=None)
- Complex Number Functions
- Reduction
tf.reduce_sum(input_tensor, reduction_indices=None, keep_dims=False, name=None)
tf.reduce_prod(input_tensor, reduction_indices=None, keep_dims=False, name=None)
tf.reduce_min(input_tensor, reduction_indices=None, keep_dims=False, name=None)
tf.reduce_max(input_tensor, reduction_indices=None, keep_dims=False, name=None)
tf.reduce_mean(input_tensor, reduction_indices=None, keep_dims=False, name=None)
tf.reduce_all(input_tensor, reduction_indices=None, keep_dims=False, name=None)
tf.reduce_any(input_tensor, reduction_indices=None, keep_dims=False, name=None)
tf.accumulate_n(inputs, shape=None, tensor_dtype=None, name=None)
- Segmentation
tf.segment_sum(data, segment_ids, name=None)
tf.segment_prod(data, segment_ids, name=None)
tf.segment_min(data, segment_ids, name=None)
tf.segment_max(data, segment_ids, name=None)
tf.segment_mean(data, segment_ids, name=None)
tf.unsorted_segment_sum(data, segment_ids, num_segments, name=None)
tf.sparse_segment_sum(data, indices, segment_ids, name=None)
tf.sparse_segment_mean(data, indices, segment_ids, name=None)
- Sequence Comparison and Indexing
Training
- Optimizers
- Gradient Computation
- Gradient Clipping
- Decaying the learning rate
- Moving Averages
- Coordinator and QueueRunner
- Summary Operations
tf.scalar_summary(tags, values, collections=None, name=None)
tf.image_summary(tag, tensor, max_images=None, collections=None, name=None)
tf.histogram_summary(tag, values, collections=None, name=None)
tf.nn.zero_fraction(value, name=None)
tf.merge_summary(inputs, collections=None, name=None)
tf.merge_all_summaries(key='summaries')
- Adding Summaries to Event Files
- Training utilities
Class tensorflow::Tensor
Member Summary
tensorflow::Tensor::Tensor()
- Default Tensor constructor. Creates a 1-dimension, 0-element float tensor.
tensorflow::Tensor::Tensor(DataType type, const TensorShape &shape)
- Creates a Tensor of the given
type
andshape
.
- Creates a Tensor of the given
tensorflow::Tensor::Tensor(Allocator *a, DataType type, const TensorShape &shape)
- Creates a tensor with the input
type
andshape
, using the allocatora
to allocate the underlying buffer.
- Creates a tensor with the input
tensorflow::Tensor::Tensor(DataType type)
- Creates an uninitialized Tensor of the given data type.
tensorflow::Tensor::Tensor(const Tensor &other)
tensorflow::Tensor::~Tensor()
- Copy constructor.
DataType tensorflow::Tensor::dtype() const
- Returns the data type.
const TensorShape& tensorflow::Tensor::shape() const
- Returns the shape of the tensor.
int tensorflow::Tensor::dims() const
- Convenience accessor for the tensor shape.
int64 tensorflow::Tensor::dim_size(int d) const
- Convenience accessor for the tensor shape.
int64 tensorflow::Tensor::NumElements() const
- Convenience accessor for the tensor shape.
bool tensorflow::Tensor::IsSameSize(const Tensor &b) const
bool tensorflow::Tensor::IsInitialized() const
- Has this Tensor been initialized?
size_t tensorflow::Tensor::TotalBytes() const
- Returns the estimated memory usage of this tensor.
Tensor& tensorflow::Tensor::operator=(const Tensor &other)
- Assign operator. This tensor shares other’s underlying storage.
bool tensorflow::Tensor::CopyFrom(const Tensor &other, const TensorShape &shape) TF_MUST_USE_RESULT
- Copy the other tensor into this tensor and reshape it.
Tensor tensorflow::Tensor::Slice(int64 dim0_start, int64 dim0_limit) const
- Slice this tensor along the 1st dimension.
bool tensorflow::Tensor::FromProto(const TensorProto &other) TF_MUST_USE_RESULT
- Parse
other
and construct the tensor.
- Parse
bool tensorflow::Tensor::FromProto(Allocator *a, const TensorProto &other) TF_MUST_USE_RESULT
void tensorflow::Tensor::AsProtoField(TensorProto *proto) const
- Fills in
proto
with*this
tensor’s content.
- Fills in
void tensorflow::Tensor::AsProtoTensorContent(TensorProto *proto) const
TTypes<T>::Vec tensorflow::Tensor::vec()
- Return the tensor data as an
Eigen::Tensor
with the type and sizes of thisTensor
.
- Return the tensor data as an
TTypes::Matrix tensorflow::Tensor::matrix()
TTypes< T, NDIMS >::Tensor tensorflow::Tensor::tensor()
TTypes<T>::Flat tensorflow::Tensor::flat()
- Return the tensor data as an
Eigen::Tensor
of the data type and a specified shape.
- Return the tensor data as an
TTypes::UnalignedFlat tensorflow::Tensor::unaligned_flat()
TTypes::Matrix tensorflow::Tensor::flat_inner_dims()
TTypes::Matrix tensorflow::Tensor::flat_outer_dims()
TTypes< T, NDIMS >::Tensor tensorflow::Tensor::shaped(gtl::ArraySlice< int64 > new_sizes)
TTypes< T, NDIMS >::UnalignedTensor tensorflow::Tensor::unaligned_shaped(gtl::ArraySlice< int64 > new_sizes)
TTypes< T >::Scalar tensorflow::Tensor::scalar()
- Return the Tensor data as a
TensorMap
of fixed size 1:TensorMap<TensorFixedSize<T, 1>>
.
- Return the Tensor data as a
TTypes<T>::ConstVec tensorflow::Tensor::vec() const
- Const versions of all the methods above.
TTypes::ConstMatrix tensorflow::Tensor::matrix() const
TTypes< T, NDIMS >::ConstTensor tensorflow::Tensor::tensor() const
TTypes::ConstFlat tensorflow::Tensor::flat() const
TTypes::UnalignedConstFlat tensorflow::Tensor::unaligned_flat() const
TTypes::ConstMatrix tensorflow::Tensor::flat_inner_dims() const
TTypes::ConstMatrix tensorflow::Tensor::flat_outer_dims() const
TTypes< T, NDIMS >::ConstTensor tensorflow::Tensor::shaped(gtl::ArraySlice< int64 > new_sizes) const
TTypes< T, NDIMS >::UnalignedConstTensor tensorflow::Tensor::unaligned_shaped(gtl::ArraySlice< int64 > new_sizes) const
TTypes< T >::ConstScalar tensorflow::Tensor::scalar() const
string tensorflow::Tensor::SummarizeValue(int64 max_entries) const
- Render the first
max_entries
values in*this
into a string.
- Render the first
string tensorflow::Tensor::DebugString() const
- A human-readable summary of the tensor suitable for debugging.
void tensorflow::Tensor::FillDescription(TensorDescription *description) const
StringPiece tensorflow::Tensor::tensor_data() const
- Returns a
StringPiece
mapping the current tensor’s buffer.
- Returns a
Constants, Sequences, and Random Values
- Constant Value Tensors
- Sequences
- Random Tensors
- Examples:
tf.random_normal(shape, mean=0.0, stddev=1.0, dtype=tf.float32, seed=None, name=None)
tf.truncated_normal(shape, mean=0.0, stddev=1.0, dtype=tf.float32, seed=None, name=None)
tf.random_uniform(shape, minval=0.0, maxval=1.0, dtype=tf.float32, seed=None, name=None)
tf.random_shuffle(value, seed=None, name=None)
tf.set_random_seed(seed)