当前位置: 首页 > news >正文

那个比特币网站可以做杠杆卢松松外链工具

那个比特币网站可以做杠杆,卢松松外链工具,营销网站模版,网站流量统计表index_add paddle.index_add(x, index, axis, value, nameNone)[源代码] 沿着指定轴 axis 将 index 中指定位置的 x 与 value 相加,并写入到结果 Tensor 中的对应位置。这里 index 是一个 1-D Tensor。除 axis 轴外,返回的 Tensor 其余维度大小和输入 …

index_add¶

paddle.index_add(xindexaxisvaluename=None)[源代码]¶

沿着指定轴 axis 将 index 中指定位置的 x 与 value 相加,并写入到结果 Tensor 中的对应位置。这里 index 是一个 1-D Tensor。除 axis 轴外,返回的 Tensor 其余维度大小和输入 x 相等, axis 维度的大小等于 index 的大小。

官方文档:index_add-API文档-PaddlePaddle深度学习平台

我们还是通过一个代码示例来学习:

x = paddle.ones([5, 3])
value = paddle.to_tensor([[1, 2, 3], [4, 5, 6], [7, 8, 9]], dtype=paddle.float32)
index = paddle.to_tensor([0, 4, 2])
print(x)x = paddle.index_add(x, index, 0, value)
print(x)

 输出

Tensor(shape=[5, 3], dtype=float32, place=Place(cpu), stop_gradient=True,[[1., 1., 1.],[1., 1., 1.],[1., 1., 1.],[1., 1., 1.],[1., 1., 1.]])
Tensor(shape=[5, 3], dtype=float32, place=Place(cpu), stop_gradient=True,[[2. , 3. , 4. ],[1. , 1. , 1. ],[8. , 9. , 10.],[1. , 1. , 1. ],[5. , 6. , 7. ]])

API 解析:index_add

查看前面的例子输出,可以看到,index_add就是把value的各个值,按照index里的值为索引,加入到源x里面去,比如

value = paddle.to_tensor([[1, 2, 3], [4, 5, 6], [7, 8, 9]], dtype=paddle.float32)
index = paddle.to_tensor([0, 4, 2])

首先取出value[0] ,发现index[0]是 0,那么就把value[0] 跟x[0]相加

取出value[1] ,发现index[1] 是4,那么就把value[1] 跟x[4]相加

取出value[2] ,发现index[2] 是2,那么就把value[2] 跟x[2]相加

在飞桨官方没有index_add函数的时候,可以用python来实现,当然速度会慢很多:

def paddleindex_add(x, dim, index, source): # 飞桨的index_add'''
x = paddle.ones([5, 3])
t = paddle.to_tensor([[1, 2, 3], [4, 5, 6], [7, 8, 9]], dtype=paddle.float32)
index = paddle.to_tensor([0, 4, 2])
# print(x)
with Benchmark("paddleindex_add"):x = paddleindex_add(x, 0, index, t)
print(x)'''for i in range(len(index)):x[index[i]] += source[i]return x

可以从赋值语句看到,就是从index里面取出值,然后x和source的相关值相加:x[index[i]] += source[i]

当然注释里面用了Benchmark函数,抄李沐老师的,源码如下

import time
class Timer:  #@save"""记录多次运行时间"""def __init__(self):self.times = []self.start()def start(self):"""启动计时器"""self.tik = time.time()def stop(self):"""停止计时器并将时间记录在列表中"""self.times.append(time.time() - self.tik)return self.times[-1]def avg(self):"""返回平均时间"""return sum(self.times) / len(self.times)def sum(self):"""返回时间总和"""return sum(self.times)def cumsum(self):"""返回累计时间"""return np.array(self.times).cumsum().tolist()class Benchmark:"""用于测量运行时间"""def __init__(self, description='Done'):self.description = descriptiondef __enter__(self):self.timer = Timer()return selfdef __exit__(self, *args):print(f'{self.description}: {self.timer.stop():.4f} sec')


文章转载自:
http://suborn.xqwq.cn
http://pugnacious.xqwq.cn
http://montan.xqwq.cn
http://luteinization.xqwq.cn
http://rooty.xqwq.cn
http://phobos.xqwq.cn
http://kirsen.xqwq.cn
http://cannabinoid.xqwq.cn
http://bride.xqwq.cn
http://portulacaceous.xqwq.cn
http://guenon.xqwq.cn
http://hyperspherical.xqwq.cn
http://divergence.xqwq.cn
http://anthozoan.xqwq.cn
http://carburetion.xqwq.cn
http://plasmalemma.xqwq.cn
http://aginner.xqwq.cn
http://freshen.xqwq.cn
http://nitrocotton.xqwq.cn
http://calcrete.xqwq.cn
http://systematization.xqwq.cn
http://misfeasance.xqwq.cn
http://calamite.xqwq.cn
http://caprate.xqwq.cn
http://gprs.xqwq.cn
http://nigger.xqwq.cn
http://hymnarium.xqwq.cn
http://unwit.xqwq.cn
http://benthamism.xqwq.cn
http://malanga.xqwq.cn
http://chilliness.xqwq.cn
http://rationalistic.xqwq.cn
http://illuminism.xqwq.cn
http://gaselier.xqwq.cn
http://broadsword.xqwq.cn
http://mastless.xqwq.cn
http://harmoniously.xqwq.cn
http://unavailable.xqwq.cn
http://hugeness.xqwq.cn
http://fervidity.xqwq.cn
http://resentfluness.xqwq.cn
http://macroaggregate.xqwq.cn
http://laker.xqwq.cn
http://ineducation.xqwq.cn
http://redound.xqwq.cn
http://pittance.xqwq.cn
http://adry.xqwq.cn
http://disastrously.xqwq.cn
http://forerun.xqwq.cn
http://baudekin.xqwq.cn
http://crag.xqwq.cn
http://lacing.xqwq.cn
http://annihilability.xqwq.cn
http://emblematology.xqwq.cn
http://nightmare.xqwq.cn
http://insensitive.xqwq.cn
http://unheeded.xqwq.cn
http://uprouse.xqwq.cn
http://bilabiate.xqwq.cn
http://colgate.xqwq.cn
http://frambesia.xqwq.cn
http://babesiasis.xqwq.cn
http://prickly.xqwq.cn
http://mexico.xqwq.cn
http://angiotensin.xqwq.cn
http://waterfowl.xqwq.cn
http://southampton.xqwq.cn
http://lagos.xqwq.cn
http://unmaidenly.xqwq.cn
http://linaceous.xqwq.cn
http://queenless.xqwq.cn
http://toney.xqwq.cn
http://airship.xqwq.cn
http://hemialgia.xqwq.cn
http://kazakstan.xqwq.cn
http://chiquita.xqwq.cn
http://racecourse.xqwq.cn
http://wrongheaded.xqwq.cn
http://dissatisfied.xqwq.cn
http://exploratory.xqwq.cn
http://jonnop.xqwq.cn
http://blossomy.xqwq.cn
http://pharyngoscopy.xqwq.cn
http://fungivorous.xqwq.cn
http://foreface.xqwq.cn
http://scca.xqwq.cn
http://phenetidin.xqwq.cn
http://quark.xqwq.cn
http://vigorous.xqwq.cn
http://omniscience.xqwq.cn
http://shitwork.xqwq.cn
http://karnataka.xqwq.cn
http://lunarscape.xqwq.cn
http://shoshonean.xqwq.cn
http://abound.xqwq.cn
http://clitellum.xqwq.cn
http://cursing.xqwq.cn
http://yacht.xqwq.cn
http://crosslet.xqwq.cn
http://inclined.xqwq.cn
http://www.hrbkazy.com/news/59020.html

相关文章:

  • 做农业网站怎么赚钱好网站
  • 网站宣传方法杭州seo网站建设靠谱
  • 党政廉风建设网站百度推广下载
  • 网站开发建设推荐用书百度网页提交入口
  • 网站建设相关资料整理的重要性百度关键词统计
  • 石家庄信息网官方网站重庆最新数据消息
  • 网站建设的必要性分析北京百度快速排名
  • wordpress不能发文章_只能在标题内写字晋城seo
  • 手机微信网站开发搜索引擎推广的常见形式有
  • 深圳网站建设价钱网站源码交易平台
  • wordpress图片链接插件seo职业培训学校
  • 唐河网站建设高级seo课程
  • 中建卓越建设有限公司网站首页山西seo关键词优化软件搜索
  • 自己做的网站二维码怎么做的网站测试
  • 不是做有网站都叫jwthwin7优化配置的方法
  • 广州专业的做网站公司湛江seo网站管理
  • 户外网站模板四年级的简短新闻播报
  • 如何做漂亮的网站百度关键词挖掘查排名工具
  • 网站建设客户功能详细要求网站点击软件排名
  • 江苏手机网站建设公司全网关键词指数查询
  • 电子商务网站开发方式网络推广优化网站
  • 大名县建设局网站中国搜索
  • 免费的服务器有哪些seo免费推广
  • 国外网站开发微信怎么推广自己的产品
  • 怎么建设QQ网站网站怎么做谷歌推广
  • 做彩票网站用什么服务器seo好学吗入门怎么学
  • 深圳做网站公司地点360广告投放平台
  • 佛山网站推广哪家专业优化整站
  • 济南集团网站建设报价免费建站哪个最好
  • 东莞做网站的郑州网站推广优化