tensorlayer学习日志2_chapter2_2.6.1~2

import numpy as np
import tensorlayer as tl

x = np.asarray([['a','a'],['b','b'],['c','c'],['d','d'],['e','e'],['f','f']])
y = np.asarray([0,1,2,3,4,5])
# x与y的元素个数要相同,否则会报错
for xx, yy in tl.iterate.minibatches(inputs=x, targets=y,batch_size=2,shuffle=False):
	print(xx, yy)

print('~~~~~~~~~~~~~~~')

# 下面两种输入法貎似也行
m = np.array([['a','a'],['b','b'],['c','c'],['d','d'],['e','e'],['f','f']])
n = np.array([0,1,2,3,4,5])

for mm, nn in tl.iterate.minibatches(inputs=m, targets=n,batch_size=2,shuffle=True):
	print(mm, nn)

print('~~~~~~~~~~~~~~~')

f = [['a','a'],['b','b'],['c','c'],['d','d'],['e','e'],['f','f']]
t = [0,1,2,3,4,5]


for ff, tt in tl.iterate.minibatches(inputs=f, targets=t,batch_size=3,shuffle=False):
	print(ff, tt)

上面2.6.1的例子很奇怪,试过np.array与直接 定义个列表好像也没什么影响~~,不一定要np.asarray~~情况如下:

[['a' 'a']
 ['b' 'b']] [0 1]
[['c' 'c']
 ['d' 'd']] [2 3]
[['e' 'e']
 ['f' 'f']] [4 5]
~~~~~~~~~~~~~~~
[['e' 'e']
 ['a' 'a']] [4 0]
[['c' 'c']
 ['b' 'b']] [2 1]
[['f' 'f']
 ['d' 'd']] [5 3]
~~~~~~~~~~~~~~~
[['a', 'a'], ['b', 'b'], ['c', 'c']] [0, 1, 2]
[['d', 'd'], ['e', 'e'], ['f', 'f']] [3, 4, 5]
[Finished in 4.3s]

下面是2.6.2的例子,还是很顺利的,就是要注意# tl.logging.set_verbosity(tl.logging.DEBUG)要注释掉,不然会报错,说是tensorlayer还没logging这个功能,另一个是network = tl.layers.DenseLayer(network, n_units=10, act=tf.identity, name='output')这行的act要定义个算法,

https://github.com/tensorlayer/te

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值