I don't understand the “Shape inconsistent” error using mxnet
up vote
0
down vote
favorite
Coming from Keras, I try to reproduce my simple model with MXNet to make prediction using Module.
I'm using that simple dataset: https://archive.ics.uci.edu/ml/machine-learning-databases/wine/wine.data
I've got 13 inputs (from alcohol to Proline) that I want to send to the model, and I need to classify the first column that is "wine type", so I create a nd.array that have 3 entries.
x = data.values[: , 1:14]
y = data.values[:, 0]
X = mx.nd.array(x)
Y =
for i, v in enumerate(y):
d = [0,0,0]
d[int(v)-1] = 1
Y.append(d)
Y = mx.nd.array(Y)
Y.shape, X.shape
# ((178, 3), (178, 13))
Then I create the model and a NDIterator:
net = mx.symbol.Variable('winechemical')
net = mx.symbol.FullyConnected(net, num_hidden=64)
net = mx.symbol.Activation(net, act_type='relu')
net = mx.symbol.FullyConnected(net, num_hidden=32)
net = mx.symbol.Activation(net, act_type='relu')
net = mx.symbol.FullyConnected(net, num_hidden=16)
net = mx.symbol.SoftmaxOutput(net, name='wineclass')
model = Module(symbol=net, context=mx.cpu(),
data_names=['winechemical'],
label_names=['wineclass_label'])
gen = mx.io.NDArrayIter(X, label=Y,
batch_size=10,
shuffle=True, data_name='winechemical',
label_name='wineclass_label')
But when I try to "train" the model using the "fit" method, I got this error:
model.fit(gen, num_epoch=5)
[...]
Error in operator wineclass: Shape inconsistent, Provided = [10,3], inferred shape=[10]
I'm pretty sure that I don't understand the shape to uses as I'm coming from Keras that use different shape... But where am I wrong ?
Thanks for your help.
python mxnet
add a comment |
up vote
0
down vote
favorite
Coming from Keras, I try to reproduce my simple model with MXNet to make prediction using Module.
I'm using that simple dataset: https://archive.ics.uci.edu/ml/machine-learning-databases/wine/wine.data
I've got 13 inputs (from alcohol to Proline) that I want to send to the model, and I need to classify the first column that is "wine type", so I create a nd.array that have 3 entries.
x = data.values[: , 1:14]
y = data.values[:, 0]
X = mx.nd.array(x)
Y =
for i, v in enumerate(y):
d = [0,0,0]
d[int(v)-1] = 1
Y.append(d)
Y = mx.nd.array(Y)
Y.shape, X.shape
# ((178, 3), (178, 13))
Then I create the model and a NDIterator:
net = mx.symbol.Variable('winechemical')
net = mx.symbol.FullyConnected(net, num_hidden=64)
net = mx.symbol.Activation(net, act_type='relu')
net = mx.symbol.FullyConnected(net, num_hidden=32)
net = mx.symbol.Activation(net, act_type='relu')
net = mx.symbol.FullyConnected(net, num_hidden=16)
net = mx.symbol.SoftmaxOutput(net, name='wineclass')
model = Module(symbol=net, context=mx.cpu(),
data_names=['winechemical'],
label_names=['wineclass_label'])
gen = mx.io.NDArrayIter(X, label=Y,
batch_size=10,
shuffle=True, data_name='winechemical',
label_name='wineclass_label')
But when I try to "train" the model using the "fit" method, I got this error:
model.fit(gen, num_epoch=5)
[...]
Error in operator wineclass: Shape inconsistent, Provided = [10,3], inferred shape=[10]
I'm pretty sure that I don't understand the shape to uses as I'm coming from Keras that use different shape... But where am I wrong ?
Thanks for your help.
python mxnet
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Coming from Keras, I try to reproduce my simple model with MXNet to make prediction using Module.
I'm using that simple dataset: https://archive.ics.uci.edu/ml/machine-learning-databases/wine/wine.data
I've got 13 inputs (from alcohol to Proline) that I want to send to the model, and I need to classify the first column that is "wine type", so I create a nd.array that have 3 entries.
x = data.values[: , 1:14]
y = data.values[:, 0]
X = mx.nd.array(x)
Y =
for i, v in enumerate(y):
d = [0,0,0]
d[int(v)-1] = 1
Y.append(d)
Y = mx.nd.array(Y)
Y.shape, X.shape
# ((178, 3), (178, 13))
Then I create the model and a NDIterator:
net = mx.symbol.Variable('winechemical')
net = mx.symbol.FullyConnected(net, num_hidden=64)
net = mx.symbol.Activation(net, act_type='relu')
net = mx.symbol.FullyConnected(net, num_hidden=32)
net = mx.symbol.Activation(net, act_type='relu')
net = mx.symbol.FullyConnected(net, num_hidden=16)
net = mx.symbol.SoftmaxOutput(net, name='wineclass')
model = Module(symbol=net, context=mx.cpu(),
data_names=['winechemical'],
label_names=['wineclass_label'])
gen = mx.io.NDArrayIter(X, label=Y,
batch_size=10,
shuffle=True, data_name='winechemical',
label_name='wineclass_label')
But when I try to "train" the model using the "fit" method, I got this error:
model.fit(gen, num_epoch=5)
[...]
Error in operator wineclass: Shape inconsistent, Provided = [10,3], inferred shape=[10]
I'm pretty sure that I don't understand the shape to uses as I'm coming from Keras that use different shape... But where am I wrong ?
Thanks for your help.
python mxnet
Coming from Keras, I try to reproduce my simple model with MXNet to make prediction using Module.
I'm using that simple dataset: https://archive.ics.uci.edu/ml/machine-learning-databases/wine/wine.data
I've got 13 inputs (from alcohol to Proline) that I want to send to the model, and I need to classify the first column that is "wine type", so I create a nd.array that have 3 entries.
x = data.values[: , 1:14]
y = data.values[:, 0]
X = mx.nd.array(x)
Y =
for i, v in enumerate(y):
d = [0,0,0]
d[int(v)-1] = 1
Y.append(d)
Y = mx.nd.array(Y)
Y.shape, X.shape
# ((178, 3), (178, 13))
Then I create the model and a NDIterator:
net = mx.symbol.Variable('winechemical')
net = mx.symbol.FullyConnected(net, num_hidden=64)
net = mx.symbol.Activation(net, act_type='relu')
net = mx.symbol.FullyConnected(net, num_hidden=32)
net = mx.symbol.Activation(net, act_type='relu')
net = mx.symbol.FullyConnected(net, num_hidden=16)
net = mx.symbol.SoftmaxOutput(net, name='wineclass')
model = Module(symbol=net, context=mx.cpu(),
data_names=['winechemical'],
label_names=['wineclass_label'])
gen = mx.io.NDArrayIter(X, label=Y,
batch_size=10,
shuffle=True, data_name='winechemical',
label_name='wineclass_label')
But when I try to "train" the model using the "fit" method, I got this error:
model.fit(gen, num_epoch=5)
[...]
Error in operator wineclass: Shape inconsistent, Provided = [10,3], inferred shape=[10]
I'm pretty sure that I don't understand the shape to uses as I'm coming from Keras that use different shape... But where am I wrong ?
Thanks for your help.
python mxnet
python mxnet
asked Nov 10 at 11:00
Metal3d
2,0031520
2,0031520
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
My god, sorry... I didn't see that I let 16 outputs instead of 3...
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
My god, sorry... I didn't see that I let 16 outputs instead of 3...
add a comment |
up vote
0
down vote
My god, sorry... I didn't see that I let 16 outputs instead of 3...
add a comment |
up vote
0
down vote
up vote
0
down vote
My god, sorry... I didn't see that I let 16 outputs instead of 3...
My god, sorry... I didn't see that I let 16 outputs instead of 3...
answered Nov 10 at 11:09
Metal3d
2,0031520
2,0031520
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53238271%2fi-dont-understand-the-shape-inconsistent-error-using-mxnet%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password