它给了我下面的错误时test_model叫做:类型错误:切片索引必须是整数
TypeError: slice indices must be integers or None or have an __index__ method
但我打电话test_model一个整数(特定批次)。 Inputtest是浮动列表的列表,标签是一个整数的向量。我不确定问题是什么。
def optimize(learning_rate = 0.1,n_epochs = 1000, batch_size = 600):
n_train_batches = len(inputt)//batch_size
n_val_batches = len(inputsdev)//batch_size
n_test_batches = len(inputstest)//batch_size
rng = numpy.random.RandomState(1234)
index = T.lscalar('index')
x = T.ivector('x')
y = T.ivector('y')
classifier = Regression(x, n_in = 150, n_out = 24)
cost = classifier.negative_log_likelihood(labelt)
test_model = theano.function(inputs = [index], outputs = classifier.errors(y),givens = { x: inputstest[index * batch_size:(index + 1) * batch_size], y : labeltes[index * batch_size:(index + 1) * batch_size]})
你能发布完整的堆栈跟踪吗 – Selcuk
你能清楚地解释你的问题吗? –
什么是'T.lscalar('index')'?有可能是,它不是'int',并且将其乘以'int'并不会产生类似'int'的东西。 – ShadowRanger