You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.
Gluon Reshape() behaves differently for NDArray and Symbol.
NDArray -> Does the reshape IN-place
Symbol -> Does the reshape Out-of-place
Error Message
(Paste the complete error message. Please also include stack trace by setting environment variable DMLC_LOG_STACK_TRACE_DEPTH=10 before running your script.)
To Reproduce
import mxnet as mx
from mxnet.gluon import nn
class HybridNet(nn.HybridBlock):
def init(self, **kwargs):
super(HybridNet, self).init(**kwargs)
def hybrid_forward(self, F, x):
y = x.reshape(-1)
y = F.square(y, out = y)
return x+y
model = HybridNet()
model.initialize()
x = mx.nd.array([1,2,3])
print(model(x))
model.hybridize()
x = mx.nd.array([1,2,3])
print(model(x))
gautham-kollu
changed the title
Gluon Reshape behaves differently for NDArray and Symbol
Gluon Reshape does in-place for NDArray and out-of-place for Symbol
Jan 29, 2020
In Gluon one should not specify where the output is stored using out= argument. In the future, Gluon should automatically detect and warn (or throw execption) on such case.
Description
Gluon Reshape() behaves differently for NDArray and Symbol.
NDArray -> Does the reshape IN-place
Symbol -> Does the reshape Out-of-place
Error Message
(Paste the complete error message. Please also include stack trace by setting environment variable
DMLC_LOG_STACK_TRACE_DEPTH=10
before running your script.)To Reproduce
import mxnet as mx
from mxnet.gluon import nn
class HybridNet(nn.HybridBlock):
def init(self, **kwargs):
super(HybridNet, self).init(**kwargs)
model = HybridNet()
model.initialize()
x = mx.nd.array([1,2,3])
print(model(x))
model.hybridize()
x = mx.nd.array([1,2,3])
print(model(x))
Running the above on CPU
[ 2. 8. 18.]
<NDArray 3 @cpu(0)>
[ 2. 6. 12.]
<NDArray 3 @cpu(0)>
Steps to reproduce
(Paste the commands you ran that produced the error.)
What have you tried to solve it?
Environment
We recommend using our script for collecting the diagnositc information. Run the following command and paste the outputs below:
The text was updated successfully, but these errors were encountered: