它給了我下面的錯誤時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