Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

FC with bias ndim > 1 fails with MKLDNN #15032

Closed
anirudh2290 opened this issue May 22, 2019 · 11 comments
Closed

FC with bias ndim > 1 fails with MKLDNN #15032

anirudh2290 opened this issue May 22, 2019 · 11 comments

Comments

@anirudh2290
Copy link
Member

Minimum reproducible example:

import numpy as np
import mxnet as mx
from mxnet.test_utils import *
def test_fully_connected():
      data = mx.sym.var("data")
      fc_weight = mx.sym.var("weight")
      fc_bias = mx.sym.var("bias")
      fc = mx.sym.FullyConnected(data=data, weight=fc_weight, bias=fc_bias, num_hidden=10, no_bias=False, name='fc')
      data = mx.nd.random.uniform(shape=(5, 5, 5, 13), dtype=np.float32)
      fc_weight = mx.nd.random.uniform(shape=(10, 325), dtype=np.float32)
      fc_bias = mx.nd.random.uniform(shape=(10), dtype=np.float32)
      fc_bias2 = mx.nd.random.uniform(shape=(10, 1), dtype=np.float32)
      data_np = data.asnumpy().reshape(5, 325)
      fc_weight_np = np.transpose(fc_weight.asnumpy())
      fc_bias_np = fc_bias.asnumpy()
      res = np.dot(data_np, fc_weight_np) + fc_bias.asnumpy()
      check_symbolic_forward(fc, {'data': data_np, 'weight': fc_weight.asnumpy(), 'bias': fc_bias_np}, {'fc_output': res})
      check_numeric_gradient(fc, {'data': data_np, 'weight': fc_weight.asnumpy(), 'bias': fc_bias_np},
                             numeric_eps=1e-2, rtol=1e-4, atol=1e-2)
      # TODO: Fix Bug when bias has ndim > 1
      check_symbolic_forward(fc, {'data': data_np, 'weight': fc_weight.asnumpy(), 'bias': fc_bias2.asnumpy()}, {'fc_output': res})
@mxnet-label-bot
Copy link
Contributor

Hey, this is the MXNet Label Bot.
Thank you for submitting the issue! I will try and suggest some labels so that the appropriate MXNet community members can help resolve it.
Here are my recommended labels: Bug

@TaoLv
Copy link
Member

TaoLv commented May 22, 2019

@anirudh2290 Thank you for reporting. What does the error log look like? And what behavior is expected when bias ndim > 1?

@TaoLv
Copy link
Member

TaoLv commented May 22, 2019

@anirudh2290 I see in document bias is defined as 1D with size of num_hidden: https://mxnet.incubator.apache.org/versions/master/api/python/ndarray/ndarray.html#mxnet.ndarray.FullyConnected

@pengzhao-intel
Copy link
Contributor

@anirudh2290 any update? Do we need to fix or close this in 1.5?

@pinaraws
Copy link

@mxnet-label-bot remove[Bug]

@marcoabreu marcoabreu removed the Bug label May 24, 2019
@pinaraws
Copy link

@mxnet-label-bot add[Feature request]

@anirudh2290
Copy link
Member Author

@pengzhao-intel @TaoLv Sorry for the late reply. Thanks for bringing up the documentation. Currnetly it core dumps and better to change it to have a better error message. I would still consider it a bug , although it may be trivial to fix.

@pengzhao-intel
Copy link
Contributor

Thanks for the suggestion. It sounds good and will update the error message.

@pengzhao-intel
Copy link
Contributor

@rongzha1 please take a look for the documentation of FC

@rongzha1
Copy link
Contributor

rongzha1 commented Nov 1, 2019

OK. Will fix in PR 16692

@pengzhao-intel
Copy link
Contributor

fixed and closing

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

8 participants