Theano와 함께 전달 전파를 코딩하려고했습니다.Theano를 사용하여 forward_propagation을 계산하십시오.
class hiddenLayer():
""" Hidden Layer class
"""
def __init__(self, n_in, n_out):
rng = np.random
self.W = shared(np.asarray(rng.uniform(low=-np.sqrt(6./(n_in + n_out)),
high=np.sqrt(6./(n_in + n_out)),
size=(n_in, n_out)),
dtype=T.config.floatX),
name='W')
self.b = shared(np.zeros(n_out, dtype=T.config.floatX), name='b')
self.x = T.dvector('x')
self.a = T.tanh(T.dot(self.x, self.W) + self.b)
self.W_sum = shared(np.zeros([n_in, n_out]), name='W_sum')
self.gw = 0
self.gb = 0
내가 hiddenLayer의 목록을 설정하려는 theano 가져 오기 기능에서 NP 로 수입 NumPy와 공유 theano 가져 오기에서 T 로
수입 theano.tensor : 나는 다음과 같이 클래스 이름 hiddenLayer을 정의 현재의 hiddenLayer는 다음 hiddenLayer의 입력입니다. 마지막으로 나는 함수 앞으로의 이름이 오류가 발생하고 코드는 다음과 같다 구입 정의 :
def init_network(n_in, n_out, sl, x, y):
l = []
for i in range(sl):
l.append(hiddenLayer(n_in, n_out))
for i in range(sl):
if i == 0:
l[i].x = x
elif i < sl-1:
l[i].x = l[i-1].a
else:
l[i].x = l[i-1].a
y = l[i].a
return x, y, l
x = T.dvector('x')
y = T.dvector('y')
x, y, l = init_network(3, 3, 3, x, y)
forward = function(inputs=[x], outputs=y)
오류 메시지는 다음과 같습니다과 어떻게 해결하는 문제가 무엇인지 왜
theano.compile.function_module.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: x.
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'.
당신이 말해 수 그것? 감사합니다