2016-06-19 2 views
0

신경망을 가르치려고 시도하면서 deeplearning.net에서 Theano 튜토리얼을 통해 작업을 시작했습니다. 방금 튜토리얼의 모든 코드 행을 복사하여 붙여 넣었으므로 예상치 못한 오류가 발생했습니다. 틀린 것은 무엇이든간에 작은 것이고 나는 단지 그것을 살펴보고 있지만 어떤 도움이 많이 감사 할 것입니다. 감사합니다Theano 튜토리얼 : UnusedInputError : theano.function

http://deeplearning.net/software/theano/tutorial/examples.html#copying-functions

import theano 
import theano.tensor as T 
state = theano.shared(0) 
inc = T.iscalar('inc') 
accumulator = theano.function([inc], state, updates=[(state, state+inc)]) 
accumulator(10) 
print(state.get_value()) 

new_state = theano.shared(0) 
new_accumulator = accumulator.copy(swap={state:new_state}) 
new_accumulator(100) 

print(state.get_value()) 
print(new_state.get_value()) 

null_accumulator = accumulator.copy(delete_updates=True) 


--------------------------------------------------------------------------- 
UnusedInputError       Traceback (most recent call last) 
<ipython-input-20-5d1acb597345> in <module>() 
----> 1 null_accumulator = accumulator.copy(delete_updates=True) 

/home/mcamp/anaconda3/lib/python3.5/site-packages/theano/compile/function_module.py in copy(self, share_memory, swap, delete_updates, name, profile) 
    719         # can contain inplace. DebugMode check 
    720         # that. 
--> 721         accept_inplace=True, 
    722        ).create(input_storage, 
    723           storage_map=new_storage_map) 

/home/mcamp/anaconda3/lib/python3.5/site-packages/theano/compile/function_module.py in __init__(self, inputs, outputs, mode, accept_inplace, function_builder, profile, on_unused_input, fgraph, output_keys) 
    1413 
    1414   # Check if some input variables are unused 
-> 1415   self._check_unused_inputs(inputs, outputs, on_unused_input) 
    1416 
    1417   # Make a list of (SymbolicInput|SymblicInputKits, indices, 

/home/mcamp/anaconda3/lib/python3.5/site-packages/theano/compile/function_module.py in _check_unused_inputs(self, inputs, outputs, on_unused_input) 
    1551     elif on_unused_input == 'raise': 
    1552      raise UnusedInputError(msg % (inputs.index(i), 
-> 1553             i.variable, err_msg)) 
    1554     else: 
    1555      raise ValueError("Invalid value for keyword " 

UnusedInputError: theano.function was asked to create a function computing outputs given certain inputs, but the provided input variable at index 0 is not part of the computational graph needed to compute the outputs: inc. 
To make this error into a warning, you can pass the parameter on_unused_input='warn' to theano.function. To disable it completely, use on_unused_input='ignore'. 

답변

0

나는 theano에 새로운 해요, 난 그냥이 다 퉜다. 그것은 튜토리얼의 버그 인 것 같습니다. 오류 메시지는 on_unused_input 매개 변수를 사용하여 오류를 표시하지 않을 것을 제안하지만 이는 copy의 키워드 인수가 아닙니다. 분명히 그것은 function으로 전달되어야합니다. 그래서 만약 누적는 다음과 같이 작성 :

accumulator = theano.function([inc], state, 
    updates=[(state, state+inc)], on_unused_input='ignore') 

다음 오류가 사라집니다. (이것은 원래의 함수의 속성을 변경해야하는 이상적인 솔루션과 같습니다.)