theano java_Theano:调用Theano函数的论据

python的本质使我很难找到一种如何调用theano函数的正式定义 .

当给出长度为4的矩阵 batch 列表时,我打电话给

validationFunction(batch[0],batch[1],batch[2],batch[3])

这很有效 .

我打电话的时候

validationFunction(batch)

要么

validationFunction((list(batch))

它抱怨:

validationError += validationFunction(batch) # [0],batch[1], batch[2], batch[3])

File "/usr/lib64/python2.7/site-packages/theano/compile/function_module.py", line 786, in __call__

allow_downcast=s.allow_downcast)

File "/usr/lib64/python2.7/site-packages/theano/tensor/type.py", line 149, in filter

converted_data = theano._asarray(data, self.dtype)

File "/usr/lib64/python2.7/site-packages/theano/misc/safe_asarray.py", line 33, in _asarray

rval = numpy.asarray(a, dtype=dtype, order=order)

File "/usr/lib64/python2.7/site-packages/numpy/core/numeric.py", line 474, in asarray

return array(a, dtype, copy=False, order=order)

ValueError: ('Bad input argument to theano function with name "dummy.py:96" at index 0(0-based)', 'could not broadcast input array from shape (7,3) into shape (7)')

我有一个符号输入变量列表和相应的minibatches列表 . 批处理的格式为:print(“batch singular = \ n0:{} \ n1:{} \ n2:{} \ n3:{}” . format(批处理[0],批处理[1],批处理[2]分批[3]))

0:[[3.0 3.0 2.0]

[3.0 2.0 5.0]

[2.0 5.0 3.0]

[5.0 3.0 4.0]

[3.0 4.0 3.0]

[4.0 3.0 2.0]

[3.0 2.0 6.0]]

1:[[5.0 3.0 4.0]

[3.0 4.0 3.0]

[4.0 3.0 2.0]

[3.0 2.0 6.0]

[2.0 6.0 6.0]

[6.0 6.0 6.0]

[6.0 6.0 2.0]]

2:[[3.0 2.0 14.0]

[2.0 2.0 14.0]

[6.0 2.0 14.0]

[6.0 2.0 14.0]

[6.0 2.0 14.0]

[2.0 2.0 14.0]

[4.0 2.0 14.0]]

3:[[2.0]

[6.0]

[6.0]

[6.0]

[2.0]

[4.0]

[4.0]]

所以基本上,如何在不硬编码1 ... n的情况下调用validationFunction(a [0],a [1],...,a [n-1])?参数的定义是什么?

该功能已定义

validationFunction= theano.function(inputVars + [targetVar], testLoss)

其中inputVars是theano矩阵的列表,targetVar是theano矩阵 . 我应该以不同的方式定义功能吗? inputVars + [targetVar] 创建了我的三个输入和一个目标的列表 .

我真的花了很多时间与theano及其风格,但有些东西记录得太紧凑了 .

输入可以作为变量或In实例给出 . 在实例中也有一个变量,但是它们附加了一些关于应该如何使用与该变量对应的调用时参数的额外信息 . 同样,Out实例可以附加有关如何返回输出变量的信息 .

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值