tf常用方法分析(Python)

本文介绍了TensorFlow中几个重要的函数,包括矩阵乘法tf.matmul、激活函数如tf.nn.relu及tf.sigmoid等。这些函数在神经网络搭建过程中发挥关键作用。
部署运行你感兴趣的模型镜像

列举几个常用的方法:

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))

您可能感兴趣的与本文相关的镜像

TensorFlow-v2.15

TensorFlow-v2.15

TensorFlow

TensorFlow 是由Google Brain 团队开发的开源机器学习框架,广泛应用于深度学习研究和生产环境。 它提供了一个灵活的平台,用于构建和训练各种机器学习模型

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值