google / seq2seq

A general-purpose encoder-decoder framework for Tensorflow
https://google.github.io/seq2seq/
Apache License 2.0
5.61k stars 1.3k forks source link

TypeError: in method 'TF_GraphToFunction_wrapper', argument 2 of type 'char const *' #324

Open ljwcqupt opened 6 years ago

ljwcqupt commented 6 years ago

This is my first time to use seq2seq,and this problem confused me about one week.

tensorflow 1.8 python 2.7

I don't know how to solve this problem.


[@nmyjs_104_69 seq2seq]# sh toy_train.sh ./train_model/nmt_tutorial INFO:tensorflow:Loading config from /search/odin/Nick/queryRewrite/seq2seq/example_configs/nmt_sample.yml INFO:tensorflow:Loading config from /search/odin/Nick/queryRewrite/seq2seq/example_configs/train_seq2seq.yml INFO:tensorflow:Loading config from /search/odin/Nick/queryRewrite/seq2seq/example_configs/text_metrics_bpe.yml INFO:tensorflow:Final Config: buckets: 10,20,30,40 default_params:

WARNING:tensorflow:Ignoring config flag: default_params INFO:tensorflow:Setting save_checkpoints_secs to 600 WARNING:tensorflow:From /search/odin/Nick/queryRewrite/seq2seq/bin/train.py:272: run (from tensorflow.contrib.learn.python.learn.learn_runner) is deprecated and will be removed in a future version. Instructions for updating: Use tf.estimator.train_and_evaluate. WARNING:tensorflow:From /search/odin/Nick/queryRewrite/seq2seq/bin/train.py:135: init (from tensorflow.contrib.learn.python.learn.estimators.run_config) is deprecated and will be removed in a future version. Instructions for updating: When switching to tf.estimator.Estimator, use tf.estimator.RunConfig instead. INFO:tensorflow:Creating ParallelTextInputPipeline in mode=train INFO:tensorflow: ParallelTextInputPipeline: !!python/unicode 'num_epochs': null !!python/unicode 'shuffle': true !!python/unicode 'source_delimiter': !!python/unicode ' ' !!python/unicode 'source_files': [/search/odin/Nick/queryRewrite/seq2seq/bin/data/nmt_data/toy_copy/train/sources.txt] !!python/unicode 'target_delimiter': !!python/unicode ' ' !!python/unicode 'target_files': [/search/odin/Nick/queryRewrite/seq2seq/bin/data/nmt_data/toy_copy/train/targets.txt]

INFO:tensorflow:Creating ParallelTextInputPipeline in mode=eval INFO:tensorflow: ParallelTextInputPipeline: !!python/unicode 'num_epochs': 1 !!python/unicode 'shuffle': false !!python/unicode 'source_delimiter': !!python/unicode ' ' !!python/unicode 'source_files': [/search/odin/Nick/queryRewrite/seq2seq/bin/data/nmt_data/toy_copy/dev/sources.txt] !!python/unicode 'target_delimiter': !!python/unicode ' ' !!python/unicode 'target_files': [/search/odin/Nick/queryRewrite/seq2seq/bin/data/nmt_data/toy_copy/dev/targets.txt]

WARNING:tensorflow:From /usr/lib/python2.7/site-packages/tensorflow/contrib/learn/python/learn/estimators/estimator.py:1179: init (from tensorflow.contrib.learn.python.learn.estimators.estimator) is deprecated and will be removed in a future version. Instructions for updating: Please replace uses of any Estimator from tf.contrib.learn with an Estimator from tf.estimator.* INFO:tensorflow:Using config: {'_save_checkpoints_secs': 600, '_num_ps_replicas': 0, '_keep_checkpoint_max': 5, '_task_type': None, '_train_distribute': None, '_is_chief': True, '_cluster_spec': <tensorflow.python.training.server_lib.ClusterSpec object at 0x7610150>, '_model_dir': './train_model/nmt_tutorial', '_save_checkpoints_steps': None, '_keep_checkpoint_every_n_hours': 4, '_session_config': None, '_tf_random_seed': None, '_save_summary_steps': 100, '_environment': 'local', '_num_worker_replicas': 0, '_task_id': 0, '_log_step_count_steps': 100, '_tf_config': gpu_oSyncReplicasOptimizerHook: {}

INFO:tensorflow:Creating TrainSampleHook in mode=train INFO:tensorflow: TrainSampleHook: {!!python/unicode 'every_n_secs': null, !!python/unicode 'every_n_steps': 1000, !!python/unicode 'source_delimiter': !!python/unicode ' ', !!python/unicode 'target_delimiter': !!python/unicode ' '}

INFO:tensorflow:Creating LogPerplexityMetricSpec in mode=eval INFO:tensorflow: LogPerplexityMetricSpec: {}

INFO:tensorflow:Creating BleuMetricSpec in mode=eval INFO:tensorflow: BleuMetricSpec: {!!python/unicode 'eos_token': !!python/unicode 'SEQUENCE_END', !!python/unicode 'postproc_fn': !!python/unicode 'seq2seq.data.postproc.strip_bpe', !!python/unicode 'separator': !!python/unicode ' ', !!python/unicode 'sos_token': !!python/unicode 'SEQUENCE_START'}

INFO:tensorflow:Creating RougeMetricSpec in mode=eval INFO:tensorflow: RougeMetricSpec: {!!python/unicode 'eos_token': !!python/unicode 'SEQUENCE_END', !!python/unicode 'postproc_fn': !!python/unicode 'seq2seq.data.postproc.strip_bpe', !!python/unicode 'rouge_type': !!python/unicode 'rouge_1/f_score', !!python/unicode 'separator': !!python/unicode ' ', !!python/unicode 'sos_token': !!python/unicode 'SEQUENCE_START'}

INFO:tensorflow:Creating RougeMetricSpec in mode=eval INFO:tensorflow: RougeMetricSpec: {!!python/unicode 'eos_token': !!python/unicode 'SEQUENCE_END', !!python/unicode 'postproc_fn': !!python/unicode 'seq2seq.data.postproc.strip_bpe', !!python/unicode 'rouge_type': !!python/unicode 'rouge_1/r_score', !!python/unicode 'separator': !!python/unicode ' ', !!python/unicode 'sos_token': !!python/unicode 'SEQUENCE_START'}

INFO:tensorflow:Creating RougeMetricSpec in mode=eval INFO:tensorflow: RougeMetricSpec: {!!python/unicode 'eos_token': !!python/unicode 'SEQUENCE_END', !!python/unicode 'postproc_fn': !!python/unicode 'seq2seq.data.postproc.strip_bpe', !!python/unicode 'rouge_type': !!python/unicode 'rouge_1/p_score', !!python/unicode 'separator': !!python/unicode ' ', !!python/unicode 'sos_token': !!python/unicode 'SEQUENCE_START'}

INFO:tensorflow:Creating RougeMetricSpec in mode=eval INFO:tensorflow: RougeMetricSpec: {!!python/unicode 'eos_token': !!python/unicode 'SEQUENCE_END', !!python/unicode 'postproc_fn': !!python/unicode 'seq2seq.data.postproc.strip_bpe', !!python/unicode 'rouge_type': !!python/unicode 'rouge_2/f_score', !!python/unicode 'separator': !!python/unicode ' ', !!python/unicode 'sos_token': !!python/unicode 'SEQUENCE_START'}

INFO:tensorflow:Creating RougeMetricSpec in mode=eval INFO:tensorflow: RougeMetricSpec: {!!python/unicode 'eos_token': !!python/unicode 'SEQUENCE_END', !!python/unicode 'postproc_fn': !!python/unicode 'seq2seq.data.postproc.strip_bpe', !!python/unicode 'rouge_type': !!python/unicode 'rouge_2/r_score', !!python/unicode 'separator': !!python/unicode ' ', !!python/unicode 'sos_token': !!python/unicode 'SEQUENCE_START'}

INFO:tensorflow:Creating RougeMetricSpec in mode=eval INFO:tensorflow: RougeMetricSpec: {!!python/unicode 'eos_token': !!python/unicode 'SEQUENCE_END', !!python/unicode 'postproc_fn': !!python/unicode 'seq2seq.data.postproc.strip_bpe', !!python/unicode 'rouge_type': !!python/unicode 'rouge_2/p_score', !!python/unicode 'separator': !!python/unicode ' ', !!python/unicode 'sos_token': !!python/unicode 'SEQUENCE_START'}

INFO:tensorflow:Creating RougeMetricSpec in mode=eval INFO:tensorflow: RougeMetricSpec: {!!python/unicode 'eos_token': !!python/unicode 'SEQUENCE_END', !!python/unicode 'postproc_fn': !!python/unicode 'seq2seq.data.postproc.strip_bpe', !!python/unicode 'rouge_type': !!python/unicode 'rouge_l/f_score', !!python/unicode 'separator': !!python/unicode ' ', !!python/unicode 'sos_token': !!python/unicode 'SEQUENCE_START'}

WARNING:tensorflow:From seq2seq/contrib/experiment.py:26: init (from tensorflow.contrib.learn.python.learn.experiment) is deprecated and will be removed in a future version. Instructions for updating: Please switch to tf.estimator.train_and_evaluate. You will also have to convert to a tf.estimator.Estimator. INFO:tensorflow:Training model for 1000 steps INFO:tensorflow:Creating AttentionSeq2Seq in mode=train INFO:tensorflow: AttentionSeq2Seq: !!python/unicode 'attention.class': !!python/unicode 'seq2seq.decoders.attention.AttentionLayerBahdanau' !!python/unicode 'attention.params': {num_units: 256} !!python/unicode 'bridge.class': !!python/unicode 'seq2seq.models.bridges.ZeroBridge' !!python/unicode 'bridge.params': {} !!python/unicode 'decoder.class': !!python/unicode 'seq2seq.decoders.AttentionDecoder' !!python/unicode 'decoder.params': rnn_cell: cell_class: GRUCell cell_params: {num_units: 256} dropout_input_keep_prob: 0.8 dropout_output_keep_prob: 1.0 num_layers: 2 !!python/unicode 'embedding.dim': 256 !!python/unicode 'embedding.init_scale': 0.04 !!python/unicode 'embedding.share': false !!python/unicode 'encoder.class': !!python/unicode 'seq2seq.encoders.BidirectionalRNNEncoder' !!python/unicode 'encoder.params': rnn_cell: cell_class: GRUCell cell_params: {num_units: 256} dropout_input_keep_prob: 0.8 dropout_output_keep_prob: 1.0 num_layers: 1 !!python/unicode 'inference.beam_search.beam_width': 0 !!python/unicode 'inference.beam_search.choose_successors_fn': !!python/unicode 'choose_top_k' !!python/unicode 'inference.beam_search.length_penalty_weight': 0.0 !!python/unicode 'optimizer.clip_embed_gradients': 0.1 !!python/unicode 'optimizer.clip_gradients': 5.0 !!python/unicode 'optimizer.learning_rate': 0.0001 !!python/unicode 'optimizer.lr_decay_rate': 0.99 !!python/unicode 'optimizer.lr_decay_steps': 100 !!python/unicode 'optimizer.lr_decay_type': !!python/unicode '' !!python/unicode 'optimizer.lr_min_learning_rate': 1.0e-12 !!python/unicode 'optimizer.lr_staircase': false !!python/unicode 'optimizer.lr_start_decay_at': 0 !!python/unicode 'optimizer.lr_stop_decay_at': 2147483647 !!python/unicode 'optimizer.name': !!python/unicode 'Adam' !!python/unicode 'optimizer.params': {} !!python/unicode 'optimizer.sync_replicas': 0 !!python/unicode 'optimizer.sync_replicas_to_aggregate': 0 !!python/unicode 'source.max_seq_len': 50 !!python/unicode 'source.reverse': false !!python/unicode 'target.max_seq_len': 50 !!python/unicode 'vocab_source': !!python/unicode '/search/odin/Nick/queryRewrite/seq2seq/bin/data/nmt_data/toy_copy/train/vocab.sources.txt' !!python/unicode 'vocab_target': !!python/unicode '/search/odin/Nick/queryRewrite/seq2seq/bin/data/nmt_data/toy_copy/train/vocab.targets.txt'

INFO:tensorflow:Creating vocabulary lookup table of size 22 INFO:tensorflow:Creating vocabulary lookup table of size 22 INFO:tensorflow:Creating BidirectionalRNNEncoder in mode=train INFO:tensorflow: BidirectionalRNNEncoder: init_scale: 0.04 rnn_cell: cell_class: GRUCell cell_params: {num_units: 256} dropout_input_keep_prob: 0.8 dropout_output_keep_prob: 1.0 model_fn_results = self._model_fn(features, labels, kwargs) File "/search/odin/Nick/queryRewrite/seq2seq/bin/train.py", line 183, in model_fn return model(features, labels, params) File "seq2seq/models/model_base.py", line 146, in call return self._build(features, labels, params) File "seq2seq/models/seq2seq_model.py", line 298, in _build decoderoutput, , = self.decode(encoder_output, features, labels) File "seq2seq/graph_utils.py", line 38, in func_wrapper return templated_func(*args, *kwargs) File "/usr/lib/python2.7/site-packages/tensorflow/python/ops/template.py", line 464, in call result = self._call_func(args, kwargs) File "/usr/lib/python2.7/site-packages/tensorflow/python/ops/template.py", line 406, in _call_func result = self._func(args, kwargs) File "seq2seq/models/basic_seq2seq.py", line 125, in decode labels) File "seq2seq/models/basic_seq2seq.py", line 88, in _decode_train return decoder(decoder_initial_state, helper_train) File "seq2seq/graph_module.py", line 57, in call return self._template(*args, kwargs) File "/usr/lib/python2.7/site-packages/tensorflow/python/ops/template.py", line 455, in call result = self._call_func(args, kwargs) File "/usr/lib/python2.7/site-packages/tensorflow/python/ops/template.py", line 406, in _call_func result = self._func(*args, kwargs) File "seq2seq/decoders/rnn_decoder.py", line 120, in _build maximum_iterations=maximum_iterations) File "seq2seq/contrib/seq2seq/decoder.py", line 287, in dynamic_decode swap_memory=swap_memory) File "/usr/lib/python2.7/site-packages/tensorflow/python/ops/control_flow_ops.py", line 3224, in while_loop result = loop_context.BuildLoop(cond, body, loop_vars, shape_invariants) File "/usr/lib/python2.7/site-packages/tensorflow/python/ops/control_flow_ops.py", line 2956, in BuildLoop pred, body, original_loop_vars, loop_vars, shape_invariants) File "/usr/lib/python2.7/site-packages/tensorflow/python/ops/control_flow_ops.py", line 2893, in _BuildLoop body_result = body(packed_vars_for_body) File "seq2seq/contrib/seq2seq/decoder.py", line 240, in body decoder_finished) = decoder.step(time, inputs, state) File "seq2seq/decoders/attention_decoder.py", line 167, in step self.compute_output(cell_output) File "seq2seq/decoders/attention_decoder.py", line 121, in compute_output values_length=self.attention_values_length) File "seq2seq/graph_module.py", line 57, in call return self._template(args, kwargs) File "/usr/lib/python2.7/site-packages/tensorflow/python/ops/template.py", line 455, in call result = self._call_func(args, kwargs) File "/usr/lib/python2.7/site-packages/tensorflow/python/ops/template.py", line 406, in _call_func result = self._func(*args, kwargs) File "seq2seq/decoders/attention.py", line 111, in _build scores = self.score_fn(att_keys, att_query) File "seq2seq/decoders/attention.py", line 150, in score_fn return att_sum_bahdanau(v_att, keys, query) File "/usr/lib/python2.7/site-packages/tensorflow/python/framework/function.py", line 503, in call self.add_to_graph(ops.get_default_graph()) File "/usr/lib/python2.7/site-packages/tensorflow/python/framework/function.py", line 484, in add_to_graph self._create_definition_if_needed() File "/usr/lib/python2.7/site-packages/tensorflow/python/framework/function.py", line 319, in _create_definition_if_needed self._create_definition_if_needed_impl() File "/usr/lib/python2.7/site-packages/tensorflow/python/framework/function.py", line 409, in _create_definition_if_needed_impl description)

*TypeError: in method 'TF_GraphToFunction_wrapper', argument 2 of type 'char const '**

originally defined at: File "seq2seq/models/basic_seq2seq.py", line 113, in decode decoder = self._create_decoder(encoder_output, features, labels) File "seq2seq/models/attention_seq2seq.py", line 63, in _create_decoder params=self.params["attention.params"], mode=self.mode) File "seq2seq/decoders/attention.py", line 59, in init GraphModule.init(self, name) File "seq2seq/graph_module.py", line 44, in init self._template = tf.maketemplate(name =self.name, func_ =self._build, create_scopenow=True) File "/usr/lib/python2.7/site-packages/tensorflow/python/ops/template.py", line 153, in make_template **kwargs)

originally defined at: File "seq2seq/models/basic_seq2seq.py", line 113, in decode decoder = self._create_decoder(encoder_output, features, labels) File "seq2seq/models/attention_seq2seq.py", line 83, in _create_decoder reverse_scores_lengths=reverse_scores_lengths) File "seq2seq/decoders/attention_decoder.py", line 75, in init super(AttentionDecoder, self).init(params, mode, name) File "seq2seq/decoders/rnn_decoder.py", line 62, in init GraphModule.init(self, name) File "seq2seq/graph_module.py", line 44, in init self._template = tf.maketemplate(name =self.name, func_ =self._build, create_scopenow=True) File "/usr/lib/python2.7/site-packages/tensorflow/python/ops/template.py", line 153, in make_template **kwargs)

originally defined at: File "seq2seq/graph_utils.py", line 37, in func_wrapper templated_func = tf.maketemplate(name, func) File "/usr/lib/python2.7/site-packages/tensorflow/python/ops/template.py", line 153, in make_template **kwargs)

scwangjing commented 6 years ago

Check the argument type, if the type is 'unicode', just cast it to the 'str' type.

yukizhao1998 commented 6 years ago

i have the same problem, do you know how to fix it now?