{"action":"created","issue":{"url":"https://api.github.com/repos/tensorflow/tensorflow/issues/9832","repository_url":"https://api.github.com/repos/tensorflow/tensorflow","labels_url":"https://api.github.com/repos/tensorflow/tensorflow/issues/9832/labels{/name}","comments_url":"https://api.github.com/repos/tensorflow/tensorflow/issues/9832/comments","events_url":"https://api.github.com/repos/tensorflow/tensorflow/issues/9832/events","html_url":"https://github.com/tensorflow/tensorflow/issues/9832","id":227920174,"number":9832,"title":"BeamSearchDecoder not working","user":{"login":"wirehack","id":16846984,"avatar_url":"https://avatars2.githubusercontent.com/u/16846984?v=3","gravatar_id":"","url":"https://api.github.com/users/wirehack","html_url":"https://github.com/wirehack","followers_url":"https://api.github.com/users/wirehack/followers","following_url":"https://api.github.com/users/wirehack/following{/other_user}","gists_url":"https://api.github.com/users/wirehack/gists{/gist_id}","starred_url":"https://api.github.com/users/wirehack/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wirehack/subscriptions","organizations_url":"https://api.github.com/users/wirehack/orgs","repos_url":"https://api.github.com/users/wirehack/repos","events_url":"https://api.github.com/users/wirehack/events{/privacy}","received_events_url":"https://api.github.com/users/wirehack/received_events","type":"User","site_admin":false},"labels":[{"id":404586594,"url":"https://api.github.com/repos/tensorflow/tensorflow/labels/stat:awaiting%20tensorflower","name":"stat:awaiting tensorflower","color":"b60205","default":false}],"state":"open","locked":false,"assignee":{"login":"ebrevdo","id":1794715,"avatar_url":"https://avatars3.githubusercontent.com/u/1794715?v=3","gravatar_id":"","url":"https://api.github.com/users/ebrevdo","html_url":"https://github.com/ebrevdo","followers_url":"https://api.github.com/users/ebrevdo/followers","following_url":"https://api.github.com/users/ebrevdo/following{/other_user}","gists_url":"https://api.github.com/users/ebrevdo/gists{/gist_id}","starred_url":"https://api.github.com/users/ebrevdo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ebrevdo/subscriptions","organizations_url":"https://api.github.com/users/ebrevdo/orgs","repos_url":"https://api.github.com/users/ebrevdo/repos","events_url":"https://api.github.com/users/ebrevdo/events{/privacy}","received_events_url":"https://api.github.com/users/ebrevdo/received_events","type":"User","site_admin":false},"assignees":[{"login":"ebrevdo","id":1794715,"avatar_url":"https://avatars3.githubusercontent.com/u/1794715?v=3","gravatar_id":"","url":"https://api.github.com/users/ebrevdo","html_url":"https://github.com/ebrevdo","followers_url":"https://api.github.com/users/ebrevdo/followers","following_url":"https://api.github.com/users/ebrevdo/following{/other_user}","gists_url":"https://api.github.com/users/ebrevdo/gists{/gist_id}","starred_url":"https://api.github.com/users/ebrevdo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ebrevdo/subscriptions","organizations_url":"https://api.github.com/users/ebrevdo/orgs","repos_url":"https://api.github.com/users/ebrevdo/repos","events_url":"https://api.github.com/users/ebrevdo/events{/privacy}","received_events_url":"https://api.github.com/users/ebrevdo/received_events","type":"User","site_admin":false}],"milestone":null,"comments":2,"created_at":"2017-05-11T08:48:49Z","updated_at":"2017-05-13T02:25:11Z","closed_at":null,"body":"I intalled TensorFlow from 2017-05-10 nightly binaries. The TensorFlow version is v1.1.0-rc2-773-g7fa0cf3 1.1.0-rc2. I have CUDA 8.0 and a Tesla K20c with 4.5G memory. My OS is Linux Ubuntu 14.04.\r\n\r\nI tried to run the following code to test the latest BeamSearchDecoder:\r\n```\r\nlstm = rnn.OutputProjectionWrapper(\r\nrnn.LayerNormBasicLSTMCell(n_hidden, dropout_keep_prob=keep_prob), n_classes)\r\ninfer_decoder = BeamSearchDecoder(lstm, \r\nembedding=lambda tokens:tf.nn.embedding_lookup(embedding_matrix, tokens),\r\nstart_tokens=start_tokens, end_token=EOS, initial_state=encoder_state, beam_width=5)\r\ndecoder_outputs_infer, decoder_state_infer, decoder_seq_infer = dynamic_decode(infer_decoder)\r\n```\r\n\r\nBut I got :\r\n```\r\nTraceback (most recent call last):\r\n  File \"/home/anxf/.local/lib/python3.4/site-packages/tensorflow/python/framework/tensor_util.py\", line 458, in make_tensor_proto\r\n    str_values = [compat.as_bytes(x) for x in proto_values]\r\n  File \"/home/anxf/.local/lib/python3.4/site-packages/tensorflow/python/framework/tensor_util.py\", line 458, in <listcomp>\r\n    str_values = [compat.as_bytes(x) for x in proto_values]\r\n  File \"/home/anxf/.local/lib/python3.4/site-packages/tensorflow/python/util/compat.py\", line 65, in as_bytes\r\n    (bytes_or_text,))\r\nTypeError: Expected binary or unicode string, got None\r\n\r\nDuring handling of the above exception, another exception occurred:\r\n\r\nTraceback (most recent call last):\r\n  File \"/home/anxf/test_beam.py\", line 127, in <module>\r\n    decoder_outputs_infer, decoder_state_infer, decoder_seq_infer = dynamic_decode(infer_decoder)\r\n  File \"/home/anxf/.local/lib/python3.4/site-packages/tensorflow/contrib/seq2seq/python/ops/decoder.py\", line 286, in dynamic_decode\r\n    swap_memory=swap_memory)\r\n  File \"/home/anxf/.local/lib/python3.4/site-packages/tensorflow/python/ops/control_flow_ops.py\", line 2705, in while_loop\r\n    result = context.BuildLoop(cond, body, loop_vars, shape_invariants)\r\n  File \"/home/anxf/.local/lib/python3.4/site-packages/tensorflow/python/ops/control_flow_ops.py\", line 2534, in BuildLoop\r\n    pred, body, original_loop_vars, loop_vars, shape_invariants)\r\n  File \"/home/anxf/.local/lib/python3.4/site-packages/tensorflow/python/ops/control_flow_ops.py\", line 2484, in _BuildLoop\r\n    body_result = body(*packed_vars_for_body)\r\n  File \"/home/anxf/.local/lib/python3.4/site-packages/tensorflow/contrib/seq2seq/python/ops/decoder.py\", line 234, in body\r\n    decoder_finished) = decoder.step(time, inputs, state)\r\n  File \"/home/anxf/.local/lib/python3.4/site-packages/tensorflow/contrib/seq2seq/python/ops/beam_search_decoder.py\", line 437, in step\r\n    length_penalty_weight=length_penalty_weight)\r\n  File \"/home/anxf/.local/lib/python3.4/site-packages/tensorflow/contrib/seq2seq/python/ops/beam_search_decoder.py\", line 516, in _beam_search_step\r\n    final_shape=[static_batch_size, beam_width])\r\n  File \"/home/anxf/.local/lib/python3.4/site-packages/tensorflow/contrib/seq2seq/python/ops/beam_search_decoder.py\", line 638, in _tensor_gather_helper\r\n    output = array_ops.reshape(output, final_shape)\r\n  File \"/home/anxf/.local/lib/python3.4/site-packages/tensorflow/python/ops/gen_array_ops.py\", line 2548, in reshape\r\n    name=name)\r\n  File \"/home/anxf/.local/lib/python3.4/site-packages/tensorflow/python/framework/op_def_library.py\", line 493, in apply_op\r\n    raise err\r\n  File \"/home/anxf/.local/lib/python3.4/site-packages/tensorflow/python/framework/op_def_library.py\", line 490, in apply_op\r\n    preferred_dtype=default_dtype)\r\n  File \"/home/anxf/.local/lib/python3.4/site-packages/tensorflow/python/framework/ops.py\", line 714, in internal_convert_to_tensor\r\n    ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref)\r\n  File \"/home/anxf/.local/lib/python3.4/site-packages/tensorflow/python/framework/constant_op.py\", line 113, in _constant_tensor_conversion_function\r\n    return constant(v, dtype=dtype, name=name)\r\n  File \"/home/anxf/.local/lib/python3.4/site-packages/tensorflow/python/framework/constant_op.py\", line 102, in constant\r\n    tensor_util.make_tensor_proto(value, dtype=dtype, shape=shape, verify_shape=verify_shape))\r\n  File \"/home/anxf/.local/lib/python3.4/site-packages/tensorflow/python/framework/tensor_util.py\", line 462, in make_tensor_proto\r\n    \"supported type.\" % (type(values), values))\r\nTypeError: Failed to convert object of type <class 'list'> to Tensor. Contents: [None, 5]. Consider casting elements to a supported type.\r\n\r\nProcess finished with exit code 1\r\n```\r\n\r\nI wonder how I can fix this problem? Or does this mean BeamSearchDecoder is still testing and does not work right now?"},"comment":{"url":"https://api.github.com/repos/tensorflow/tensorflow/issues/comments/301219688","html_url":"https://github.com/tensorflow/tensorflow/issues/9832#issuecomment-301219688","issue_url":"https://api.github.com/repos/tensorflow/tensorflow/issues/9832","id":301219688,"user":{"login":"chenghuige","id":6323467,"avatar_url":"https://avatars3.githubusercontent.com/u/6323467?v=3","gravatar_id":"","url":"https://api.github.com/users/chenghuige","html_url":"https://github.com/chenghuige","followers_url":"https://api.github.com/users/chenghuige/followers","following_url":"https://api.github.com/users/chenghuige/following{/other_user}","gists_url":"https://api.github.com/users/chenghuige/gists{/gist_id}","starred_url":"https://api.github.com/users/chenghuige/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chenghuige/subscriptions","organizations_url":"https://api.github.com/users/chenghuige/orgs","repos_url":"https://api.github.com/users/chenghuige/repos","events_url":"https://api.github.com/users/chenghuige/events{/privacy}","received_events_url":"https://api.github.com/users/chenghuige/received_events","type":"User","site_admin":false},"created_at":"2017-05-13T02:25:11Z","updated_at":"2017-05-13T02:25:11Z","body":"as @shuuki4  mentioned, one way to solve this is to reshape as [-1, beam_width] when batch size is dyanmic(None)."}}
{"actor":{"display_login":"chenghuige"}}