models icon indicating copy to clipboard operation
models copied to clipboard

Questions of run evaluator for dependency parsing

Open zhou-zh opened this issue 9 years ago • 7 comments

I hope run conll2017 baseline to predict dependency parsing , after trained the english model i got the parser_spec.textproto and the checkpoint.model. Then i started to run the evaluator.py in /dragnn/tools/, followed the guide i used those commands:

bazel run -c opt //dragnn/tools:evaluator -- \
  --master_spec="/home/zhiheng/models/syntaxnet/trained-english/parser_spec.textproto" \
  --checkpoint_file="/home/zhiheng/models/syntaxnet/trained-english/checkpoint.model" \
  --input_file="/home/zhiheng/data/UD_english/test_english.conllu

but it showed error as follows:

Traceback (most recent call last):
  File "/home/zhiheng/.cache/bazel/_bazel_zhiheng/7d6fd27fe29dcb09299b0785a4c85115/execroot/syntaxnet/bazel-out/local-opt/bin/dragnn/tools/evaluator.runfiles/__main__/dragnn/tools/evaluator.py", line 168, in <module>
    tf.app.run()
  File "/home/zhiheng/.cache/bazel/_bazel_zhiheng/7d6fd27fe29dcb09299b0785a4c85115/execroot/syntaxnet/bazel-out/local-opt/bin/dragnn/tools/evaluator.runfiles/org_tensorflow/tensorflow/python/platform/app.py", line 48, in run
    _sys.exit(main(_sys.argv[:1] + flags_passthrough))
  File "/home/zhiheng/.cache/bazel/_bazel_zhiheng/7d6fd27fe29dcb09299b0785a4c85115/execroot/syntaxnet/bazel-out/local-opt/bin/dragnn/tools/evaluator.runfiles/__main__/dragnn/tools/evaluator.py", line 108, in main
    builder = graph_builder.MasterBuilder(master_spec, hyperparam_config)
  File "/home/zhiheng/.cache/bazel/_bazel_zhiheng/7d6fd27fe29dcb09299b0785a4c85115/execroot/syntaxnet/bazel-out/local-opt/bin/dragnn/tools/evaluator.runfiles/__main__/dragnn/python/graph_builder.py", line 175, in __init__
    component_spec)
  File "/home/zhiheng/.cache/bazel/_bazel_zhiheng/7d6fd27fe29dcb09299b0785a4c85115/execroot/syntaxnet/bazel-out/local-opt/bin/dragnn/tools/evaluator.runfiles/__main__/syntaxnet/util/registry.py", line 182, in Create
    return _ResolveAndCreate(baseclass, path, subclass_name, *args, **kwargs)
  File "/home/zhiheng/.cache/bazel/_bazel_zhiheng/7d6fd27fe29dcb09299b0785a4c85115/execroot/syntaxnet/bazel-out/local-opt/bin/dragnn/tools/evaluator.runfiles/__main__/syntaxnet/util/registry.py", line 166, in _ResolveAndCreate
    subclass = _Create(baseclass, resolved_subclass_name, *args, **kwargs)
  File "/home/zhiheng/.cache/bazel/_bazel_zhiheng/7d6fd27fe29dcb09299b0785a4c85115/execroot/syntaxnet/bazel-out/local-opt/bin/dragnn/tools/evaluator.runfiles/__main__/syntaxnet/util/registry.py", line 131, in _Create
    return subclass(*args, **kwargs)
  File "/home/zhiheng/.cache/bazel/_bazel_zhiheng/7d6fd27fe29dcb09299b0785a4c85115/execroot/syntaxnet/bazel-out/local-opt/bin/dragnn/tools/evaluator.runfiles/__main__/dragnn/python/component.py", line 116, in __init__
    self.network = self.make_network(self.spec.network_unit)
  File "/home/zhiheng/.cache/bazel/_bazel_zhiheng/7d6fd27fe29dcb09299b0785a4c85115/execroot/syntaxnet/bazel-out/local-opt/bin/dragnn/tools/evaluator.runfiles/__main__/dragnn/python/component.py", line 143, in make_network
    return network_units.NetworkUnitInterface.Create(network_type, self)
  File "/home/zhiheng/.cache/bazel/_bazel_zhiheng/7d6fd27fe29dcb09299b0785a4c85115/execroot/syntaxnet/bazel-out/local-opt/bin/dragnn/tools/evaluator.runfiles/__main__/syntaxnet/util/registry.py", line 182, in Create
    return _ResolveAndCreate(baseclass, path, subclass_name, *args, **kwargs)
  File "/home/zhiheng/.cache/bazel/_bazel_zhiheng/7d6fd27fe29dcb09299b0785a4c85115/execroot/syntaxnet/bazel-out/local-opt/bin/dragnn/tools/evaluator.runfiles/__main__/syntaxnet/util/registry.py", line 166, in _ResolveAndCreate
    subclass = _Create(baseclass, resolved_subclass_name, *args, **kwargs)
  File "/home/zhiheng/.cache/bazel/_bazel_zhiheng/7d6fd27fe29dcb09299b0785a4c85115/execroot/syntaxnet/bazel-out/local-opt/bin/dragnn/tools/evaluator.runfiles/__main__/syntaxnet/util/registry.py", line 131, in _Create
    return subclass(*args, **kwargs)
  File "/home/zhiheng/.cache/bazel/_bazel_zhiheng/7d6fd27fe29dcb09299b0785a4c85115/execroot/syntaxnet/bazel-out/local-opt/bin/dragnn/tools/evaluator.runfiles/__main__/dragnn/python/wrapped_units.py", line 234, in __init__
    super(LayerNormBasicLSTMNetwork, self).__init__(component)
  File "/home/zhiheng/.cache/bazel/_bazel_zhiheng/7d6fd27fe29dcb09299b0785a4c85115/execroot/syntaxnet/bazel-out/local-opt/bin/dragnn/tools/evaluator.runfiles/__main__/dragnn/python/wrapped_units.py", line 102, in __init__
    component, init_layers=layers, init_context_layers=context_layers)
  File "/home/zhiheng/.cache/bazel/_bazel_zhiheng/7d6fd27fe29dcb09299b0785a4c85115/execroot/syntaxnet/bazel-out/local-opt/bin/dragnn/tools/evaluator.runfiles/__main__/dragnn/python/network_units.py", line 657, in __init__
    check.Gt(spec.size, 0, 'Invalid fixed feature size')
  File "/home/zhiheng/.cache/bazel/_bazel_zhiheng/7d6fd27fe29dcb09299b0785a4c85115/execroot/syntaxnet/bazel-out/local-opt/bin/dragnn/tools/evaluator.runfiles/__main__/syntaxnet/util/check.py", line 38, in Gt
    raise error('Expected (%s) > (%s): %s' % (lhs, rhs, message))
ValueError: Expected (0) > (0): Invalid fixed feature size
ERROR: Non-zero return code '1' from command: Process exited with status 1.

My system is Ubuntu 14.04.3, bazel - 0.4.5 Thanks for any help! @calberti

zhou-zh avatar Apr 16 '17 14:04 zhou-zh

Can you list the command you used to produce parser_spec.textproto and the contents of the file? From the error message, seems that the spec is incomplete.

bogatyy avatar Apr 20 '17 15:04 bogatyy

I'm getting the same error when running the baseline English model released for CoNLL 2017. Here's my invocation (running in the tensorflow/syntaxnet Docker container):

$ bazel run -c opt dragnn/tools:evaluator -- \
    --master_spec /conll2017/conll17/English/parser_spec.textproto \
    --checkpoint_file /conll2017/conll17/English/checkpoint \
    --input_file /conll2017/input.txt

INFO: Running command line: bazel-bin/dragnn/tools/evaluator --master_spec /conll2017/conll17/English/parser_spec.textproto --checkpoint_file /conll2017/conll17/English/checkpoint --input_file /conll2017/input.txt
INFO:tensorflow:Building the graph
INFO:tensorflow:[char_lstm] input_dropout_rate=1.0 recurrent_dropout_rate=0.8
Traceback (most recent call last):
  File "/root/.cache/bazel/_bazel_root/821bda42e7dedbfae9d936785dd2d125/execroot/syntaxnet/bazel-out/local-opt/bin/dragnn/tools/evaluator.runfiles/__main__/dragnn/tools/evaluator.py", line 168, in <module>
    tf.app.run()
  File "/root/.cache/bazel/_bazel_root/821bda42e7dedbfae9d936785dd2d125/execroot/syntaxnet/bazel-out/local-opt/bin/dragnn/tools/evaluator.runfiles/org_tensorflow/tensorflow/python/platform/app.py", line 48, in run
    _sys.exit(main(_sys.argv[:1] + flags_passthrough))
  File "/root/.cache/bazel/_bazel_root/821bda42e7dedbfae9d936785dd2d125/execroot/syntaxnet/bazel-out/local-opt/bin/dragnn/tools/evaluator.runfiles/__main__/dragnn/tools/evaluator.py", line 108, in main
    builder = graph_builder.MasterBuilder(master_spec, hyperparam_config)
  File "/root/.cache/bazel/_bazel_root/821bda42e7dedbfae9d936785dd2d125/execroot/syntaxnet/bazel-out/local-opt/bin/dragnn/tools/evaluator.runfiles/__main__/dragnn/python/graph_builder.py", line 175, in __init__
    component_spec)
  File "/root/.cache/bazel/_bazel_root/821bda42e7dedbfae9d936785dd2d125/execroot/syntaxnet/bazel-out/local-opt/bin/dragnn/tools/evaluator.runfiles/__main__/syntaxnet/util/registry.py", line 182, in Create
    return _ResolveAndCreate(baseclass, path, subclass_name, *args, **kwargs)
  File "/root/.cache/bazel/_bazel_root/821bda42e7dedbfae9d936785dd2d125/execroot/syntaxnet/bazel-out/local-opt/bin/dragnn/tools/evaluator.runfiles/__main__/syntaxnet/util/registry.py", line 166, in _ResolveAndCreate
    subclass = _Create(baseclass, resolved_subclass_name, *args, **kwargs)
  File "/root/.cache/bazel/_bazel_root/821bda42e7dedbfae9d936785dd2d125/execroot/syntaxnet/bazel-out/local-opt/bin/dragnn/tools/evaluator.runfiles/__main__/syntaxnet/util/registry.py", line 131, in _Create
    return subclass(*args, **kwargs)
  File "/root/.cache/bazel/_bazel_root/821bda42e7dedbfae9d936785dd2d125/execroot/syntaxnet/bazel-out/local-opt/bin/dragnn/tools/evaluator.runfiles/__main__/dragnn/python/component.py", line 116, in __init__
    self.network = self.make_network(self.spec.network_unit)
  File "/root/.cache/bazel/_bazel_root/821bda42e7dedbfae9d936785dd2d125/execroot/syntaxnet/bazel-out/local-opt/bin/dragnn/tools/evaluator.runfiles/__main__/dragnn/python/component.py", line 143, in make_network
    return network_units.NetworkUnitInterface.Create(network_type, self)
  File "/root/.cache/bazel/_bazel_root/821bda42e7dedbfae9d936785dd2d125/execroot/syntaxnet/bazel-out/local-opt/bin/dragnn/tools/evaluator.runfiles/__main__/syntaxnet/util/registry.py", line 182, in Create
    return _ResolveAndCreate(baseclass, path, subclass_name, *args, **kwargs)
  File "/root/.cache/bazel/_bazel_root/821bda42e7dedbfae9d936785dd2d125/execroot/syntaxnet/bazel-out/local-opt/bin/dragnn/tools/evaluator.runfiles/__main__/syntaxnet/util/registry.py", line 166, in _ResolveAndCreate
    subclass = _Create(baseclass, resolved_subclass_name, *args, **kwargs)
  File "/root/.cache/bazel/_bazel_root/821bda42e7dedbfae9d936785dd2d125/execroot/syntaxnet/bazel-out/local-opt/bin/dragnn/tools/evaluator.runfiles/__main__/syntaxnet/util/registry.py", line 131, in _Create
    return subclass(*args, **kwargs)
  File "/root/.cache/bazel/_bazel_root/821bda42e7dedbfae9d936785dd2d125/execroot/syntaxnet/bazel-out/local-opt/bin/dragnn/tools/evaluator.runfiles/__main__/dragnn/python/wrapped_units.py", line 234, in __init__
    super(LayerNormBasicLSTMNetwork, self).__init__(component)
  File "/root/.cache/bazel/_bazel_root/821bda42e7dedbfae9d936785dd2d125/execroot/syntaxnet/bazel-out/local-opt/bin/dragnn/tools/evaluator.runfiles/__main__/dragnn/python/wrapped_units.py", line 102, in __init__
    component, init_layers=layers, init_context_layers=context_layers)
  File "/root/.cache/bazel/_bazel_root/821bda42e7dedbfae9d936785dd2d125/execroot/syntaxnet/bazel-out/local-opt/bin/dragnn/tools/evaluator.runfiles/__main__/dragnn/python/network_units.py", line 657, in __init__
    check.Gt(spec.size, 0, 'Invalid fixed feature size')
  File "/root/.cache/bazel/_bazel_root/821bda42e7dedbfae9d936785dd2d125/execroot/syntaxnet/bazel-out/local-opt/bin/dragnn/tools/evaluator.runfiles/__main__/syntaxnet/util/check.py", line 38, in Gt
    raise error('Expected (%s) > (%s): %s' % (lhs, rhs, message))
ValueError: Expected (0) > (0): Invalid fixed feature size

Here's that parser_spec.textproto from the baseline model distribution:

component {
  name: "char_lstm"
  transition_system {
    registered_name: "char-shift-only"
    parameters {
      key: "left_to_right"
      value: "true"
    }
  }
  fixed_feature {
    name: "chars"
    fml: "char-input.text-char"
    embedding_dim: 16
  }
  network_unit {
    registered_name: "wrapped_units.LayerNormBasicLSTMNetwork"
    parameters {
      key: "hidden_layer_sizes"
      value: "256"
    }
  }
  backend {
    registered_name: "SyntaxNetComponent"
  }
  component_builder {
    registered_name: "DynamicComponentBuilder"
  }
}
component {
  name: "lookahead"
  transition_system {
    registered_name: "shift-only"
    parameters {
      key: "left_to_right"
      value: "false"
    }
  }
  linked_feature {
    name: "char_lstm"
    fml: "input.last-char-focus"
    embedding_dim: 64
    source_component: "char_lstm"
    source_translator: "identity"
    source_layer: "state_h_0"
  }
  network_unit {
    registered_name: "wrapped_units.LayerNormBasicLSTMNetwork"
    parameters {
      key: "hidden_layer_sizes"
      value: "256"
    }
  }
  backend {
    registered_name: "SyntaxNetComponent"
  }
  component_builder {
    registered_name: "DynamicComponentBuilder"
  }
}
component {
  name: "tagger"
  transition_system {
    registered_name: "tagger"
  }
  linked_feature {
    name: "lookahead"
    fml: "input.focus"
    embedding_dim: 64
    source_component: "lookahead"
    source_translator: "reverse-token"
    source_layer: "state_h_0"
  }
  network_unit {
    registered_name: "wrapped_units.LayerNormBasicLSTMNetwork"
    parameters {
      key: "hidden_layer_sizes"
      value: "256"
    }
  }
  backend {
    registered_name: "SyntaxNetComponent"
  }
  component_builder {
    registered_name: "DynamicComponentBuilder"
  }
}
component {
  name: "parser"
  transition_system {
    registered_name: "arc-standard"
  }
  fixed_feature {
    name: "labels"
    fml: "stack.child(1).label stack.child(1).sibling(-1).label stack.child(-1).label stack.child(-1).sibling(1).label stack(1).child(1).label stack(1).child(1).sibling(-1).label stack(1).child(-1).label stack(1).child(-1).sibling(1).label stack.child(2).label stack.child(-2).label stack(1).child(2).label stack(1).child(-2).label"
    embedding_dim: 16
  }
  linked_feature {
    name: "lookahead"
    fml: "input.focus"
    embedding_dim: 64
    source_component: "lookahead"
    source_translator: "reverse-token"
    source_layer: "state_h_0"
  }
  linked_feature {
    name: "tagger"
    fml: "input.focus stack.focus stack(1).focus"
    embedding_dim: 64
    source_component: "tagger"
    source_translator: "identity"
    source_layer: "state_h_0"
  }
  linked_feature {
    name: "rnn-stack"
    fml: "stack.focus stack(1).focus"
    embedding_dim: 64
    source_component: "parser"
    source_translator: "shift-reduce-step"
    source_layer: "layer_0"
  }
  network_unit {
    registered_name: "FeedForwardNetwork"
    parameters {
      key: "hidden_layer_sizes"
      value: "256"
    }
    parameters {
      key: "layer_norm_hidden"
      value: "true"
    }
  }
  backend {
    registered_name: "SyntaxNetComponent"
  }
  component_builder {
    registered_name: "DynamicComponentBuilder"
  }
}

hans avatar Apr 21 '17 18:04 hans

I re-ran the make_parser_spec script and it also does not output size keys in the resulting proto. Is there a mismatch in the code here? Or am I / are we doing something incorrectly?

hans avatar Apr 21 '17 19:04 hans

@bogatyy I also have the same problem. Can you tell us how to fix it? Thanks.

jingcangcang avatar Apr 27 '17 02:04 jingcangcang

In fact , I didn't train the whole process,that is too long,I interrupted the process during the train,i use the Ctrl +C to stop it and triggered the KeyboardInterrupt,then i use the parser_spec.textproto to run the evaluator. So is that caused the parser_spec.textproto incomplete?

zhou-zh avatar May 13 '17 12:05 zhou-zh

Test the following 2 flags : '--resource_dir=/conll2017/conll17/English' and '--complete_master_spec=true'

This completes the parser_spec.textproto with the directory data.

flags.DEFINE_string('resource_dir', '', 'Optional base directory for resources in the master spec.') flags.DEFINE_bool('complete_master_spec', False, 'Whether the master_spec ' 'needs the lexicon and other resources added to it.') .... if FLAGS.complete_master_spec: spec_builder.complete_master_spec(master_spec, None, FLAGS.resource_dir)

paul05100 avatar Jun 22 '17 18:06 paul05100

This question is better asked on StackOverflow since it is not a bug or feature request. There is also a larger community that reads questions there. Thanks!

karmel avatar Feb 24 '18 18:02 karmel