tf常用方法分析(Python)

列举几个常用的方法:

1.tf.matmul

matmul(
    a,
    b,
    transpose_a=False,
    transpose_b=False,
    adjoint_a=False,
    adjoint_b=False,
    a_is_sparse=False,
    b_is_sparse=False,
    name=None
)

Multiplies matrix a by matrix b, producing a * b.

The inputs must be matrices (or tensors of rank > 2, representing batches ofmatrices), with matching inner dimensions, possibly after transposition.

Both matrices must be of the same type. The supported types are:float16, float32, float64, int32, complex64, complex128.

Either matrix can be transposed or adjointed (conjugated and transposed) onthe fly by setting one of the corresponding flag to True. These are Falseby default.

If one or both of the matrices contain a lot of zeros, a more efficientmultiplication algorithm can be used by setting the correspondinga_is_sparse or b_is_sparse flag to True. These are False by default.This optimization is only available for plain matrices (rank-2 tensors) withdatatypes bfloat16 or float32.

2.tf.nn

The activation ops provide different types of nonlinearities for use in neuralnetworks. These include smooth nonlinearities (sigmoid, tanh, elu,softplus, and softsign), continuous but not everywhere differentiablefunctions (relu, relu6, crelu and relu_x), and random regularization(dropout).

All activation ops apply componentwise, and produce a tensor of the sameshape as the input tensor

提供几个不同的非线性激活函数。


3.tf.nn.relu

relu(
    features,
    name=None
)
ReLU激活函数 f(x) = max(x,0)


4.tf.sigmoid

sigmoid(
    x,
    name=None
)

Computes sigmoid of x element-wise.

Specifically, y = 1 / (1 + exp(-x)).


5.tf.tanh

tanh(
    x,
    name=None
)
f(x) = (1-e^(-2x)) / (1+e^(-2x))

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值