国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學(xué)院 > 開發(fā)設(shè)計(jì) > 正文

tensorflow 一些常用類和方法

2019-11-08 20:05:25
字體:
供稿:網(wǎng)友

tf.nn,tf.layers,tf.contrib的區(qū)別(V1.0)

三個(gè)模塊里都可以實(shí)現(xiàn)卷積層的操作,一直不太明白他們之間的區(qū)別。tf.nn  提供神經(jīng)網(wǎng)絡(luò)相關(guān)操作的支持,包括各種卷積操作、激活函數(shù)、pooling、歸一化、losses、分類操作、        embedding、RNN(dynamic_rnn bidirectional_dynamic_rnn raw_rnn)、Evaluationtf.layers   這個(gè)庫提供一系列的高級(jí)神經(jīng)網(wǎng)絡(luò)層、都是卷積相關(guān)的。tf.contrib.layers 提供 構(gòu)建計(jì)算圖中網(wǎng)絡(luò)層、正則化、摘要操作。是構(gòu)建計(jì)算圖的高級(jí)操作,但是contrib                   模塊包含不穩(wěn)定和實(shí)驗(yàn)性的代碼,有可能以后API會(huì)改變。內(nèi)容更豐富,支持的操作更多。

tf.reduce_mean(input_tensor, axis=None, keep_dims=False, name=None, reduction_indices=None)

Computes the mean of elements across dimensions of a tensor.

對(duì)張量的某個(gè)維度上的元素進(jìn)行平均計(jì)算

Reduces input_tensor along the dimensions given in axis. Unless keep_dims is true, the rank of the tensor is reduced by 1 for each entry in axis. If keep_dims is true, the reduced dimensions are retained with length 1.

按照給定的軸axis在某個(gè)維度上縮減張量。

If axis has no entries, all dimensions are reduced, and a tensor with a single element is returned.

如果axis沒有輸入,所有維度都進(jìn)行縮減,返回只有一個(gè)元素的張量。

For example:

# 'x' is [[1., 1.]#         [2., 2.]]tf.reduce_mean(x) ==> 1.5tf.reduce_mean(x, 0) ==> [1.5, 1.5]tf.reduce_mean(x, 1) ==> [1.,  2.]
Args:
input_tensor: The tensor to reduce. Should have numeric type. 輸入張量,數(shù)值型axis: The dimensions to reduce. If None (the default), reduces all dimensions.需要縮減的維度,如果空,縮減所有維度keep_dims: If true, retains reduced dimensions with length 1.如果真,保留縮減的維度為1name: A name for the Operation (optional).reduction_indices: The old (dePRecated) name for axis.老的方式,確定維度。——————————————————————————————————————————————————————————————————————

tf.argmax(input, axis=None, name=None, dimension=None)

tf.argmax(input, axis=None, name=None, dimension=None)

See the guide: Math > Sequence Comparison and Indexing

Returns the index with the largest value across axes of a tensor.   返回的是張量按軸找最大值的index

Args:

input: A Tensor. Must be one of the following types: float32float64int64int32uint8uint16int16int8complex64complex128qint8quint8qint32half.axis: A Tensor. Must be one of the following types: int32int64. int32, 0 <= axis < rank(input). Describes which axis of the input Tensor to reduce across. For vectors, use axis = 0.    0--找每一列   1--找每一行name: A name for the operation (optional).

Returns:

Tensor of type int64. 返回的是最大值的位置,運(yùn)行sess才能顯示值。

Defined in tensorflow/python/ops/math_ops.py.

————————————————————————————————————————————————————————————————————————

tf.reshape(tensor, shape, name=None)

Reshapes a tensor.

Given tensor, this operation returns a tensor that has the same values as tensor with shape shape.

If one component of shape is the special value -1, the size of that dimension is computed so that the total size remains constant. In particular, a shape of [-1] flattens into 1-D. At most one component of shape can be -1.

If shape is 1-D or higher, then the operation returns a tensor with shape shape filled with the values of tensor. In this case, the number of elements implied by shape must be the same as the number of elements in tensor.

如果shape中有一個(gè)位置喂-1,是為了其余位置的大小保持不變,-1的位置自適應(yīng)size。

For example:

# tensor 't' is [1, 2, 3, 4, 5, 6, 7, 8, 9]# tensor 't' has shape [9]reshape(t, [3, 3]) ==> [[1, 2, 3],                        [4, 5, 6],                        [7, 8, 9]]# tensor 't' is [[[1, 1], [2, 2]],#                [[3, 3], [4, 4]]]# tensor 't' has shape [2, 2, 2]reshape(t, [2, 4]) ==> [[1, 1, 2, 2],                        [3, 3, 4, 4]]# tensor 't' is [[[1, 1, 1],#                 [2, 2, 2]],#                [[3, 3, 3],#                 [4, 4, 4]],#                [[5, 5, 5],#                 [6, 6, 6]]]# tensor 't' has shape [3, 2, 3]# pass '[-1]' to flatten 't'reshape(t, [-1]) ==> [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6]# -1 can also be used to infer the shape# -1 is inferred to be 9:reshape(t, [2, -1]) ==> [[1, 1, 1, 2, 2, 2, 3, 3, 3],                         [4, 4, 4, 5, 5, 5, 6, 6, 6]]# -1 is inferred to be 2:reshape(t, [-1, 9]) ==> [[1, 1, 1, 2, 2, 2, 3, 3, 3],                         [4, 4, 4, 5, 5, 5, 6, 6, 6]]# -1 is inferred to be 3:reshape(t, [ 2, -1, 3]) ==> [[[1, 1, 1],                              [2, 2, 2],                              [3, 3, 3]],                             [[4, 4, 4],                              [5, 5, 5],                              [6, 6, 6]]]# tensor 't' is [7]# shape `[]` reshapes to a scalarreshape(t, []) ==> 7
Args:
tensor: A Tensor.shape: A Tensor of type int32. Defines the shape of the output tensor.name: A name for the operation (optional).
Returns:

Tensor. Has the same type as tensor


發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 关岭| 岐山县| 奉节县| 峡江县| 龙海市| 梅河口市| 浦北县| 周宁县| 罗甸县| 兴隆县| 盐亭县| 永泰县| 浦城县| 禹城市| 株洲市| 临朐县| 宁安市| 尚义县| 三台县| 正安县| 海阳市| 麟游县| 吴桥县| 江安县| 洛扎县| 承德县| 乌兰察布市| 陇西县| 孟连| 宁河县| 汽车| 循化| 兴国县| 恩施市| 商城县| 含山县| 张家界市| 黎城县| 德安县| 江山市| 江西省|