日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 人文社科 > 生活经验 >内容正文

生活经验

API pytorch tensorflow

發布時間:2023/11/28 生活经验 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 API pytorch tensorflow 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

pytorch與tensorflow API速查表

方法名稱pytrochtensorflownumpy
裁剪torch.clamp(x, min, max)tf.clip_by_value(x, min, max)np.clip(x, min, max)
取最大值torch.max(x, dim)[0]tf.max(x, axis)np.max(x, axis)
取最小值torch.min(x, dim)[0]tf.min(x, axis)np.min(x , axis)
取兩個tensor的最大值torch.max(x, y)tf.maximum(x, y)np.maximum(x, y)
取兩個tensor的最小值torch.min(x, y)torch.minimum(x, y)np.minmum(x, y)
取最大值索引torch.max(x, dim)[1]tf.argmax(x, axis)np.argmax(x, axis)
取最小值索引torch.min(x, dim)[1]tf.argmin(x, axis)np.argmin(x, axis)
比較(x > y)torch.gt(x, y)tf.greater(x, y)np.greater(x, y)
比較(x < y)torch.le(x, y)tf.less(x, y)np.less(x, y)
比較(x==y)torch.eq(x, y)tf.equal(x, y)np.equal(x, y)
比較(x!=y)torch.ne(x, y)tf.not_equal(x, y)np.not_queal(x , y)
取符合條件值的索引torch.nonzero(cond)tf.where(cond)np.where(cond)
多個tensor聚合torch.cat([x, y], dim)tf.concat([x,y], axis)np.concatenate([x,y], axis)
堆疊成一個tensortorch.stack([x1, x2], dim)tf.stack([x1, x2], axis)np.stack([x, y], axis)
tensor切成多個tensortorch.split(x1, split_size_or_sections, dim)tf.split(x1, num_or_size_splits, axis)np.split(x1, indices_or_sections, axis)
torch.unbind(x1, dim)tf.unstack(x1,axis)NULL
隨機擾亂torch.randperm(n)1tf.random_shuffle(x)np.random.shuffle(x)2 np.random.permutation(x)3
前k個值torch.topk(x, n, sorted, dim)tf.nn.top_k(x, n, sorted)NULL

  1. 該方法只能對0~n-1自然數隨機擾亂,所以先對索引隨機擾亂,然后再根據擾亂后的索引取相應的數據得到擾亂后的數據 ??

  2. 該方法會修改原值,沒有返回值 ??

  3. 該方法不會修改原值,返回擾亂后的值 ??

總結

以上是生活随笔為你收集整理的API pytorch tensorflow的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。