【问题标题】:Theano TensorVariable object has no attribute get_valueTheano TensorVariable 对象没有属性 get_value
【发布时间】:2017-02-20 01:59:05
【问题描述】:

我有以下 theano 对象:

train_set_x = cPickle.load(f)
print (train_set_x.type, train_set_x.get_value().shape)
>>TensorType(float64, matrix) (1000000L, 64L)

但是,当我尝试对其进行切片时,会再次获得形状

train_set_x = train_set_x[:100]
print (train_set_x.type)
>>TensorType(float64, matrix)
n_train_batches = train_set_x.get_value(borrow=True).shape[0]
>>AttributeError: 'TensorVariable' object has no attribute 'get_value'

谁能给我解释一下为什么切片后会出现这个错误?

谢谢

【问题讨论】:

    标签: python theano


    【解决方案1】:

    train_set_x是theano共享变量,所以不能像train_set_x = train_set_x[:100]那样设置。

    你应该尝试使用 set_value():

    train_set_x.set_value(train_set_x.get_value()[:100])
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-07-15
      • 2020-06-16
      • 2017-08-01
      • 1970-01-01
      • 1970-01-01
      • 2019-07-30
      • 1970-01-01
      • 2018-06-23
      相关资源
      最近更新 更多