2017-02-01 4 views
0

Я использую нейронную сеть, использующую Theano. Где мой размер ввода - 64 узла, скрытый уровень - 500 узлов, а выход - 1 узел.Theano ValueError: значение y_i из связанного

Мой вход - матрица (1 000 000 * 64), а выход - (1 000 000 * 1).

Я реализую свою Нейронную сеть, используя следующий учебник. http://deeplearning.net/tutorial/mlp.html#mlp

Пожалуйста, помогите!

я получаю из связанной ошибки на следующей строке его вызывает у меня ошибки

##LOADING THE DATA FROM TXT FILE 
train_set_x = numpy.loadtxt('x.txt', delimiter=',') 
train_set_y = numpy.loadtxt('y.txt', delimiter=',') 
train_set_x = theano.shared(numpy.asarray(train_set_x, 
              dtype=theano.config.floatX), 
          borrow=True) 
train_set_y = theano.shared(numpy.asarray(train_set_y, 
              dtype=theano.config.floatX), 
          borrow=True)  
train_set_y = T.cast(train_set_y, 'int32') 


.... 


##TRAINING FUNCTION 
train_model = theano.function(
     inputs=[index], 
     outputs=cost, 
     updates=updates, 
     givens={ 
      x: train_set_x[index * batch_size: (index + 1) * batch_size], 
      y: train_set_y[index * batch_size: (index + 1) * batch_size] 
     } 
    ) 

.... 

##TRAINING 
while (epoch < n_epochs) and (not done_looping): 
     epoch = epoch + 1 
     for minibatch_index in range(n_train_batches): 
      minibatch_avg_cost = train_model(minibatch_index) 

ОШИБКА:

File "NN_main.py", line 276, in test_mlp 
    minibatch_avg_cost = train_model(minibatch_index) 
    File "C:\Users\wei\Anaconda2\lib\site-packages\theano\compile\function_module.py", line 871, in __call__ 
    storage_map=getattr(self.fn, 'storage_map', None)) 
    File "C:\Users\wei\Anaconda2\lib\site-packages\theano\gof\link.py", line 314, in raise_with_op 
    reraise(exc_type, exc_value, exc_trace) 
    File "C:\Users\wei\Anaconda2\lib\site-packages\theano\compile\function_module.py", line 859, in __call__ 
    outputs = self.fn() 
ValueError: y_i value out of bounds 
Apply node that caused the error: CrossentropySoftmaxArgmax1HotWithBias(Dot22.0, b, Elemwise{Cast{int32}}.0) 
Toposort index: 21 
Inputs types: [TensorType(float64, matrix), TensorType(float64, vector), TensorType(int32, vector)] 
Inputs shapes: [(20L, 1L), (1L,), (20L,)] 
Inputs strides: [(8L, 8L), (8L,), (4L,)] 
Inputs values: ['not shown', array([ 0.]), 'not shown'] 
Outputs clients: [[Sum{acc_dtype=float64}(CrossentropySoftmaxArgmax1HotWithBias.0)], [CrossentropySoftmax1HotWithBiasDx(Elemwise{Inv}[(0, 0)].0, CrossentropySoftmaxArgmax1HotWithBias.1, Elemwise{Cast{int32}}.0)], []] 

Backtrace when the node is created(use Theano flag traceback.limit=N to make it longer): 
    File "NN_main.py", line 332, in <module> 
    test_mlp() 
    File "NN_main.py", line 193, in test_mlp 
    + L2_reg * classifier.L2_sqr 
    File "C:\wei\MyChessEngine\MyChessEngine\logistic_sgd.py", line 112, in negative_log_likelihood 
    return -T.mean(T.log(self.p_y_given_x)[T.arange(y.shape[0]), y]) 

HINT: Use the Theano flag 'exception_verbosity=high' for a debugprint and storage map footprint of this apply node. 
+0

Сегодня я столкнулся с той же проблемой, и причина в том, что я обозначил классы из 1 вместо 0. –

ответ

0

В случае, если кто еще получил ту же ошибку, я столкнулся с этой проблемой сегодня и причина в том, что я обозначил классы от 1 вместо 0.

Смежные вопросы