小编fan*_*ack的帖子

IndexError:无法将张量变量类型的切片条目强制转换为整数

我运行"ipython debugf.py",它给了我如下错误信息

IndexError                                Traceback (most recent call last)  
/home/ml/debugf.py in <module>()  
      8 fff = theano.function(inputs=[index],  
      9                         outputs=cost,  
---> 10                         givens={x: train_set_x[index: index+1]})  

IndexError: failed to coerce slice entry of type TensorVariable to integer"   
Run Code Online (Sandbox Code Playgroud)

我搜索论坛没有运气,有人可以帮忙吗?谢谢!
debugf.py:

import theano.tensor as T    
import theano    
import numpy    
index =T.lscalar()    
x=T.dmatrix()    
cost=x +index    
train_set_x=numpy.arange(100).reshape([20,5])    
fff=theano.function(inputs=[index],    
     outputs=cost,    
     givens={x:train_set_x[index: index+1]})   #<--- Error here    
Run Code Online (Sandbox Code Playgroud)

python theano

6
推荐指数
1
解决办法
3493
查看次数

标签 统计

python ×1

theano ×1