{"action":"closed","issue":{"url":"https://api.github.com/repos/dmlc/mxnet/issues/3604","repository_url":"https://api.github.com/repos/dmlc/mxnet","labels_url":"https://api.github.com/repos/dmlc/mxnet/issues/3604/labels{/name}","comments_url":"https://api.github.com/repos/dmlc/mxnet/issues/3604/comments","events_url":"https://api.github.com/repos/dmlc/mxnet/issues/3604/events","html_url":"https://github.com/dmlc/mxnet/issues/3604","id":184917508,"number":3604,"title":"NameError: name 'CNNModel' is not defined","user":{"login":"amitkb3","id":7608321,"avatar_url":"https://avatars.githubusercontent.com/u/7608321?v=3","gravatar_id":"","url":"https://api.github.com/users/amitkb3","html_url":"https://github.com/amitkb3","followers_url":"https://api.github.com/users/amitkb3/followers","following_url":"https://api.github.com/users/amitkb3/following{/other_user}","gists_url":"https://api.github.com/users/amitkb3/gists{/gist_id}","starred_url":"https://api.github.com/users/amitkb3/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amitkb3/subscriptions","organizations_url":"https://api.github.com/users/amitkb3/orgs","repos_url":"https://api.github.com/users/amitkb3/repos","events_url":"https://api.github.com/users/amitkb3/events{/privacy}","received_events_url":"https://api.github.com/users/amitkb3/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-10-24T18:24:48Z","updated_at":"2016-11-02T16:28:50Z","closed_at":"2016-11-02T16:28:50Z","body":"Hi,\n         I am getting an error in the cnn text classification example. I believe the error is how the return statement is defined as i was able to run the setup_cnn_model function step by step. I am new to python so i am not able to catch the issue.\n\n**error:**\n---\n\nNameError                                 Traceback (most recent call last)\n<ipython-input-79-41ff8a3dd1cd> in <module>()\n----> 1 cnn_model = setup_cnn_model(mx.cpu(), batch_size, sentence_size, num_embed, vocab_size, dropout=0.5, with_embedding=False)\n\n<ipython-input-78-d7501af934ba> in setup_cnn_model(ctx, batch_size, sentence_size, num_embed, vocab_size, dropout, initializer, with_embedding)\n     36     label = cnn_exec.arg_dict['softmax_label']\n     37 \n---> 38     return CNNModel(cnn_exec=cnn_exec, symbol=cnn, data=data, label=label, param_blocks=param_blocks)\n\nNameError: name 'CNNModel' is not defined\n\n**code:**\n\ndef setup_cnn_model(ctx, batch_size, sentence_size, num_embed, vocab_size,\n        dropout=0.5, initializer=mx.initializer.Uniform(0.1), with_embedding=True):\n\n```\ncnn = make_text_cnn(sentence_size, num_embed, batch_size=batch_size,\n        vocab_size=vocab_size, dropout=dropout, with_embedding=with_embedding)\narg_names = cnn.list_arguments()\n\ninput_shapes = {}\nif with_embedding:\n    input_shapes['data'] = (batch_size, 1, sentence_size, num_embed)\nelse:\n    input_shapes['data'] = (batch_size, sentence_size)\n\narg_shape, out_shape, aux_shape = cnn.infer_shape(**input_shapes)\narg_arrays = [mx.nd.zeros(s, ctx) for s in arg_shape]\nargs_grad = {}\nfor shape, name in zip(arg_shape, arg_names):\n    if name in ['softmax_label', 'data']: # input, output\n        continue\n    args_grad[name] = mx.nd.zeros(shape, ctx)\n\ncnn_exec = cnn.bind(ctx=ctx, args=arg_arrays, args_grad=args_grad, grad_req='add')\n\nparam_blocks = []\narg_dict = dict(zip(arg_names, cnn_exec.arg_arrays))\nfor i, name in enumerate(arg_names):\n    if name in ['softmax_label', 'data']: # input, output\n        continue\n    initializer(name, arg_dict[name])\n\n    param_blocks.append( (i, arg_dict[name], args_grad[name], name) )\n\nout_dict = dict(zip(cnn.list_outputs(), cnn_exec.outputs))\n\ndata = cnn_exec.arg_dict['data']\nlabel = cnn_exec.arg_dict['softmax_label']\n\nreturn CNNModel(cnn_exec=cnn_exec, symbol=cnn, data=data, label=label, param_blocks=param_blocks)\n```\n\ncnn_model = setup_cnn_model(mx.cpu(), batch_size, sentence_size, num_embed, vocab_size, dropout=0.5, with_embedding=False)\n"}}
{"actor":{"display_login":"amitkb3"}}