Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

elemwise_op_common.h:133: Check failed: assign(&dattr, (*vec)[i]) Incompatible attr in node at 0-th output: expected [2048], got [512] #10

Open
EpilogueCc opened this issue Sep 2, 2019 · 3 comments

Comments

@EpilogueCc
Copy link

how to deal with this problem

@EpilogueCc
Copy link
Author

Traceback (most recent call last):
File "/root/workspace/tasn-master/tasn-mxnet/example/tasn/train.py", line 65, in
eval_metric = evaluate.Multi_Accuracy(num=6))
File "/root/workspace/tasn-master/tasn-mxnet/example/tasn/common/fit.py", line 196, in fit
monitor = monitor)
File "/root/workspace/mxnet_python/python/mxnet/module/base_module.py", line 503, in fit
allow_missing=allow_missing, force_init=force_init)
File "/root/workspace/mxnet_python/python/mxnet/module/module.py", line 309, in init_params
_impl(desc, arr, arg_params)
File "/root/workspace/mxnet_python/python/mxnet/module/module.py", line 297, in _impl
cache_arr.copyto(arr)
File "/root/workspace/mxnet_python/python/mxnet/ndarray/ndarray.py", line 2074, in copyto
return _internal._copyto(self, out=other)
File "", line 25, in _copyto
File "/root/workspace/mxnet_python/python/mxnet/_ctypes/ndarray.py", line 92, in _imperative_invoke
ctypes.byref(out_stypes)))
File "/root/workspace/mxnet_python/python/mxnet/base.py", line 252, in check_call
raise MXNetError(py_str(_LIB.MXGetLastError()))
mxnet.base.MXNetError: [17:10:58] /v-helzhe/code/test/last/TASN/tasn-mxnet/3rdparty/mshadow/../../src/operator/tensor/../elemwise_op_common.h:133: Check failed: assign(&dattr, (*vec)[i]) Incompatible attr in node at 0-th output: expected [2048], got [512]

@EpilogueCc
Copy link
Author

"""
Adapted from https://github.com/phunterlau/iNaturalist.git

by Heliang Zheng
03/28/2019

"""
import random
import os
import argparse
import logging
logging.basicConfig(level=logging.DEBUG)
from common import fit, evaluate
import common.cub_data as data
import mxnet as mx
import numpy as np
import os, urllib
import model

if name == "main":

os.environ["MXNET_CUDNN_AUTOTUNE_DEFAULT"] = "1"
random.seed(0)
np.random.seed(0)
mx.random.seed(0)
# parse args
parser = argparse.ArgumentParser(description="fine-tune a dataset",
                                 formatter_class=argparse.ArgumentDefaultsHelpFormatter)
train = fit.add_fit_args(parser)
data.add_data_args(parser)
aug = data.add_data_aug_args(parser)
data.set_data_aug_level(parser, 1)
parser.set_defaults(image_shape = '3,512,512', num_epochs=300,
                    lr=0.1, lr_step_epochs='100,200', wd=0, mom=0)

args = parser.parse_args()
# args.gpus = 0,1,2,3
args.gpus = 1
args.data_nthreads = 128
args.batch_size = 96
args.num_classes = 200
args.num_examples = 5994
# args = "0,1,2,3,4,5,6,7"
# batch_size_per_gpu = np.int(args.batch_size/len(args.gpus.replace(',','')))
batch_size_per_gpu = np.int(args.batch_size / 1)
# load pretrained model
dir_path = os.path.dirname(os.path.realpath(__file__))

a=mx.symbol.infer_shape
print(a.shape)

prefix = 'model/resnet-50'
epoch = 0
sym, arg_params, aux_params = mx.model.load_checkpoint(prefix, epoch)


(new_sym, new_args, new_auxs) = model.tasn(
    sym, arg_params, aux_params, args.num_classes, batch_size_per_gpu)     

# train
fit.fit(args        = args,
        network     = new_sym,
        data_loader = data.get_custom_iter,
        arg_params  = new_args,
        aux_params  = new_auxs,
        label_names = (['att_net_label', 'part_net_label', 'master_net_label', 'part_net_aux_label', 'master_net_aux_label']),
        eval_metric = evaluate.Multi_Accuracy(num=6))

@liuhangfan
Copy link

hi, did you fix it?

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

No branches or pull requests

2 participants