3
假设我有一个Theano符号x
并运行以下代码。是否有身份识别功能?
x.name = "x"
y = x
y.name = "y"
当然x.name
的是那么"y"
。 有没有一个身份识别功能,可以让我做下面的事情?
x.name = "x"
y = T.identity(x)
y.name = "y"
预期的行为是y
现在看到是x
功能,并且它们都正确命名。当然Theano编译器会简单地合并这些符号,因为y
只是x
。
的原因,我问这个是因为我有像以下,其中filter
和feature
是Theano符号和nonlinear
或者是True
或False
的情况。
activation = T.dot(feature, filter)
activation.name = "activation"
response = T.nnet.sigmoid(activation) if nonlinear else activation
response.name = "response"
的问题是,在nonlinear
是False
的情况下,我activation
符号将被命名为"response"
。
我可以解决该问题的解决这个问题:
activation = T.dot(feature, filter)
activation.name = "activation"
if nonlinear:
response = T.nnet.sigmoid(activation)
response.name = "response"
else:
response = activation
response.name = "activation&response"
但身份的功能会更优雅:
activation = T.dot(feature, filter)
activation.name = "activation"
response = T.nnet.sigmoid(activation) if nonlinear else T.identity(activation)
response.name = "response"
我不熟悉Theano,但将deepcopy的帮助? –
@JayanthKoushik不,Theano符号是符号数学表达式,而不是常规的Python数据。 –