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

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

mxnet基础到提高(48)-ones和ones_like

發布時間:2025/3/12 编程问答 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 mxnet基础到提高(48)-ones和ones_like 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

返回全1元素矩陣

mxnet.ndarray.ones(shape, ctx=None, dtype=None, **kwargs)[source] Returns a new array filled with all ones, with the given shape and type.Parameters shape (int or tuple of int or list of int) – The shape of the empty array.ctx (Context, optional) – An optional device context. Defaults to the current default context (mxnet.context.current_context()).dtype (str or numpy.dtype, optional) – An optional value type (default is float32).out (NDArray, optional) – The output NDArray (default is None).Returns A new array of the specified shape filled with all ones.Return type NDArray from mxnet import nd import mxnet as mx a = mx.nd.ones(12) print(a) b = mx.nd.ones((3,4)) print(b) c=mx.nd.ones((2,8), dtype='float16').asnumpy() print(c) [1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1.] <NDArray 12 @cpu(0)>[[1. 1. 1. 1.][1. 1. 1. 1.][1. 1. 1. 1.]] <NDArray 3x4 @cpu(0)> [[1. 1. 1. 1. 1. 1. 1. 1.][1. 1. 1. 1. 1. 1. 1. 1.]]

返回相同形狀的全1元素矩陣

mxnet.ndarray.ones_like(data=None, out=None, name=None, **kwargs) Return an array of ones with the same shape and type as the input array.Parameters data (NDArray) – The inputout (NDArray, optional) – The output NDArray to hold the result.Returns out – The output of this function.Return type NDArray or list of NDArrays [[1. 2. 3.][4. 5. 6.]] <NDArray 2x3 @cpu(0)>[[1. 1. 1.][1. 1. 1.]] <NDArray 2x3 @cpu(0)> from mxnet import nd import mxnet as mx a = mx.nd.array(((1,2,3),(4,5,6))) print(a) b=mx.nd.ones_like(a) print(b)

總結

以上是生活随笔為你收集整理的mxnet基础到提高(48)-ones和ones_like的全部內容,希望文章能夠幫你解決所遇到的問題。

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