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

网站建设联/百度关键词优化专家

网站建设联,百度关键词优化专家,江门特色,免费做ppt的网站简单思路演示代码 简单代码演示,基本思路(实际中需要像后面代码一样先洗牌,且每次shuffer后顺序不同) a np.arange(100)def batch_gen(data): # 定义batch数据生成器idx 0while True:if idx10>100:idx0start idxidx 10yield data[s…

简单思路演示代码

  • 简单代码演示,基本思路(实际中需要像后面代码一样先洗牌,且每次shuffer后顺序不同)
a = np.arange(100)def batch_gen(data):  # 定义batch数据生成器idx = 0while True:if idx+10>100:idx=0start = idxidx += 10yield data[start:start+10]gen = batch_gen(a)for i in range(20):b = next(gen)  # 在循环中利用next()函数调用batch数据print(b)
  • 代码运行结果
[0 1 2 3 4 5 6 7 8 9]
[10 11 12 13 14 15 16 17 18 19]
[20 21 22 23 24 25 26 27 28 29]
[30 31 32 33 34 35 36 37 38 39]
[40 41 42 43 44 45 46 47 48 49]
[50 51 52 53 54 55 56 57 58 59]
[60 61 62 63 64 65 66 67 68 69]
[70 71 72 73 74 75 76 77 78 79]
[80 81 82 83 84 85 86 87 88 89]
[90 91 92 93 94 95 96 97 98 99]
[0 1 2 3 4 5 6 7 8 9]
[10 11 12 13 14 15 16 17 18 19]
[20 21 22 23 24 25 26 27 28 29]
[30 31 32 33 34 35 36 37 38 39]
[40 41 42 43 44 45 46 47 48 49]
[50 51 52 53 54 55 56 57 58 59]
[60 61 62 63 64 65 66 67 68 69]
[70 71 72 73 74 75 76 77 78 79]
[80 81 82 83 84 85 86 87 88 89]
[90 91 92 93 94 95 96 97 98 99]

实际batch-generator代码

  • 定义批量数据生成器
def shuffle_aligned_list(data):"""Shuffle arrays in a list by shuffling each array identically."""num = data[0].shape[0]p = np.random.permutation(num)return [d[p] for d in data]def batch_generator(data, batch_size, shuffle=True):"""Generate batches of data.Given a list of array-like objects, generate batches of a givensize by yielding a list of array-like objects corresponding to thesame slice of each input."""if shuffle:data = shuffle_aligned_list(data)batch_count = 0while True:if batch_count * batch_size + batch_size > len(data[0]):batch_count = 0if shuffle:data = shuffle_aligned_list(data)start = batch_count * batch_sizeend = start + batch_sizebatch_count += 1yield [d[start:end] for d in data]
  • 实例化批量数据生成器
# make data
x = np.arange(1,51).reshape((10,5))
y = np.arange(1,11).reshape((-1,1))# define epochs and batch_size
batch_size = 5
epochs_num = (len(x)//batch_size)*epochs# define generator
batch_gen = batch_generator([x,y],batch_size) # assign batch_gen as batch generator
  • 利用next()循环语句中调用gen
for i in range(20):batch_x,batch_y = next(batch_gen)if int(i%2)==0:print('Epoch %d'%int(i/2))print('The %d Batch_y:\n '%(i+1),batch_y.reshape((1,-1)),'\n')
Epoch 1
The 1 Batch_y:[[ 5  2  7 10  4]] The 2 Batch_y:[[1 3 6 9 8]] Epoch 2
The 3 Batch_y:[[2 3 6 8 1]] The 4 Batch_y:[[ 5  9 10  4  7]] Epoch 3
The 5 Batch_y:[[ 2 10  1  3  8]] The 6 Batch_y:[[7 9 6 5 4]] Epoch 4
The 7 Batch_y:[[2 4 5 3 6]] The 8 Batch_y:[[ 1  7  9  8 10]] Epoch 5
The 9 Batch_y:[[10  4  7  5  2]] The 10 Batch_y:[[1 8 9 6 3]] Epoch 6
The 11 Batch_y:[[6 3 8 9 7]] The 12 Batch_y:[[ 1 10  2  4  5]] Epoch 7
The 13 Batch_y:[[1 3 4 5 8]] The 14 Batch_y:[[ 9  6  7 10  2]] Epoch 8
The 15 Batch_y:[[ 7 10  5  2  9]] The 16 Batch_y:[[6 4 3 1 8]] Epoch 9
The 17 Batch_y:[[ 3 10  2  4  8]] The 18 Batch_y:[[5 6 1 7 9]] Epoch 10
The 19 Batch_y:[[ 1  4  7 10  3]] The 20 Batch_y:[[8 9 6 5 2]]
http://www.jmfq.cn/news/5251357.html

相关文章:

  • 外贸公司网站模板/百度代运营推广
  • 网站备案进度/企业网站首页
  • 南京百度网站制作/网站维护一年一般多少钱?
  • 简述建设iis网站的基本过程6/网站优化比较好的公司
  • 下载网站软件免费安装/上海公布最新情况
  • 第一个做网站的是谁/seo优化网站推广
  • 做品牌推广应该怎么做/临沂seo优化
  • 门户网站建设方案ppt/百度网页入口官网
  • 新疆建设工程云网站操作具体流程/seo引擎优化
  • 做视频网站收费标准/现在什么app引流效果好
  • 网站资源库建设报价/抖音矩阵排名软件seo
  • 贵阳哪里做网站/百度爱企查电话人工服务总部
  • 施工合同电子版/宁波百度快照优化排名
  • 广水做网站/重庆网站优化公司
  • 中国视觉设计网站/东莞网站建设市场
  • 网站怎么做app吗/营销咨询师
  • 网站建设定价/百度app推广方法
  • 武汉网址模板建站/广州网络推广平台
  • 好看的网站推荐一下/上海抖音推广
  • 做网站的参考文献有哪些/疫情优化调整
  • 西安站/在线识图
  • 网站开发与制作/西安关键词优化平台
  • 宝塔wordpress 数据库/seo综合查询站长工具关键词
  • 网站设计的主要风格/微信引流的十个方法
  • 上海手机网站建设/免费seo培训
  • 用xampp搭建wordpress/抖音seo优化排名
  • 做网站一台电脑可以吗/网站链接推广工具
  • linux做网站优势/百度快照提交入口
  • 东莞做网站公司在哪/营销型网站建设优化建站
  • 作词做曲网站/谷歌浏览器官网下载