Theano의 0, (?,), (1 ,?), (?,?) 모양과의 차이점은 무엇입니까? 제가Theano의 변수 모양의 차이점
arr = np.array([1,2,3])
정의 어레이 (3)의 어레이는 왜? 어떻게 (3,1) 배열을 정의 할 수 있습니까?
게다가, 나는 다음과 같이 코드를 작성 :
import theano.tensor as T
from theano import shared
import numpy as np
from theano import function
class hiddenLayer():
""" Hidden Layer class
"""
def __init__(self, inputs, n_in, n_out, act_func):
rng = np.random
self.W = shared(np.asarray(rng.uniform(low=-4*np.sqrt(6./(n_in + n_out)),
high=4*np.sqrt(6./(n_in + n_out)),
size=(n_in, n_out)),
dtype=T.config.floatX),
name='W')
self.inputs = inputs
self.b = shared(np.zeros(n_out, dtype=T.config.floatX), name='b')
self.x = T.dvector('x')
self.z = T.dot(self.x, self.W) + self.b
self.ac = function([self.x], self.z)
a = hiddenLayer(np.asarray([1, 2, 3], dtype=T.config.floatX), 3, 3, T.tanh)
print a.ac(a.inputs, a.z)
가 왜 오류보고!
'Expected an array-like object, but found a Variable: '
TypeError: ('Bad input argument to theano function at index 1(0-based)', 'Expected an array-like object, but found a Variable: maybe you are trying to call a function on a (possibly shared) variable instead of a numeric array?')
매우 감사를
정확히 같은 복제본은 아니지만 [관련 스레드의이 답변] (http://stackoverflow.com/a/22074424/1634191)에는'numpy.array' 모양의 차이점에 대한 설명이 있습니다. – wflynny
왜 내가 (3) 배열을 theano.function에 전달하면 위와 같이 오류가 발생합니까? x는 모양이 (?,) 인 T.dvector로 정의되며, 내가 통과하는 것은 (3,) 배열입니다. 왜 그것이 배열과 같은 객체를 기대한다고 말했습니까? – BoscoTsang