已解决
torch VS tensorflow 同功能的api
来自网友在路上 158858提问 提问时间:2023-10-27 19:37:55阅读次数: 58
最佳答案 问答题库588位专家为你答疑解惑
1、裁剪
torch.clamp(a,-0.1,0.1) ==tf.clip()
2、复制
tf.tile(a,[1,2,1])和a.repeat(1,2,1)
3、
增加维度
a.unsqueeze(0) == tf.expand_dim(a,axis=0)
4、L2归一化
def normalize(x, axis=-1):x = 1. * x / (torch.norm(x, 2, axis, keepdim=True).expand_as(x).clamp_min(1e-12))return x
l2_normal_a = normalize(a) == tf.l2_normal(a,axis=1)
5、交换维度
b.permute(1,0) == tf.transopose(b,[1,0])
6.类型转换
tf.cast(a,float16)==a.half()
6、常量
torch.tensor([[1,2,3],[4,5,6.0]]) == tf.constant ([[1,2,3],[4,5,6.0]])
7、torch.zeros_like ==tf. zeros_like ones_like==ones_like where=where
torch.mean=tf.reduce_mean()
查看全文
99%的人还看了
相似问题
猜你感兴趣
版权申明
本文"torch VS tensorflow 同功能的api":http://eshow365.cn/6-26282-0.html 内容来自互联网,请自行判断内容的正确性。如有侵权请联系我们,立即删除!
- 上一篇: 工控安全与网络安全有什么不同?
- 下一篇: 配置Sentinel 控制台