Merge branch 'feature/improve-optimizer-handling' of https://github.com/explosion/spaCy into feature/improve-optimizer-handling

This commit is contained in:
Matthew Honnibal 2017-11-06 15:06:58 +01:00
commit 6859c21f0e
2 changed files with 51 additions and 8 deletions

View File

@ -200,8 +200,8 @@ p
+cell Config parameters. +cell Config parameters.
+row("foot") +row("foot")
+cell yields +cell returns
+cell tuple +cell callable
+cell An optimizer. +cell An optimizer.
+h(2, "use_params") Language.use_params +h(2, "use_params") Language.use_params

View File

@ -262,13 +262,13 @@ p
+tag method +tag method
p p
| Initialize the pipe for training, using data exampes if available. If no | Initialise the pipe for training, using data exampes if available. If no
| model has been initialized yet, the model is added. | model has been initialised yet, the model is added.
+aside-code("Example"). +aside-code("Example").
#{VARNAME} = #{CLASSNAME}(nlp.vocab) #{VARNAME} = #{CLASSNAME}(nlp.vocab)
nlp.pipeline.append(#{VARNAME}) nlp.pipeline.append(#{VARNAME})
#{VARNAME}.begin_training(pipeline=nlp.pipeline) optimizer = #{VARNAME}.begin_training(pipeline=nlp.pipeline)
+table(["Name", "Type", "Description"]) +table(["Name", "Type", "Description"])
+row +row
@ -285,6 +285,36 @@ p
| Optional list of #[+api("pipe") #[code Pipe]] components that | Optional list of #[+api("pipe") #[code Pipe]] components that
| this component is part of. | this component is part of.
+row
+cell #[code sgd]
+cell callable
+cell
| An optional optimizer. Should take two arguments #[code weights]
| and #[code gradient], and an optional ID. Will be created via
| #[+api(CLASSNAME.toLowerCase() + "#create_optimizer") #[code create_optimizer]]
| if not set.
+row("foot")
+cell returns
+cell callable
+cell An optimizer.
+h(2, "create_optimizer") #{CLASSNAME}.create_optimizer
+tag method
p
| Create an optmizer for the pipeline component.
+aside-code("Example").
#{VARNAME} = #{CLASSNAME}(nlp.vocab)
optimizer = #{VARNAME}.create_optimizer()
+table(["Name", "Type", "Description"])
+row("foot")
+cell returns
+cell callable
+cell The optimizer.
+h(2, "use_params") #{CLASSNAME}.use_params +h(2, "use_params") #{CLASSNAME}.use_params
+tag method +tag method
+tag contextmanager +tag contextmanager
@ -309,9 +339,14 @@ p Modify the pipe's model, to use the given parameter values.
p Add a new label to the pipe. p Add a new label to the pipe.
+aside-code("Example"). if CLASSNAME == "Tagger"
#{VARNAME} = #{CLASSNAME}(nlp.vocab) +aside-code("Example").
#{VARNAME}.add_label('MY_LABEL') #{VARNAME} = #{CLASSNAME}(nlp.vocab)
#{VARNAME}.add_label('MY_LABEL', {POS: 'NOUN'})
else
+aside-code("Example").
#{VARNAME} = #{CLASSNAME}(nlp.vocab)
#{VARNAME}.add_label('MY_LABEL')
+table(["Name", "Type", "Description"]) +table(["Name", "Type", "Description"])
+row +row
@ -319,6 +354,14 @@ p Add a new label to the pipe.
+cell unicode +cell unicode
+cell The label to add. +cell The label to add.
if CLASSNAME == "Tagger"
+row
+cell #[code values]
+cell dict
+cell
| Optional values to map to the label, e.g. a tag map
| dictionary.
+h(2, "to_disk") #{CLASSNAME}.to_disk +h(2, "to_disk") #{CLASSNAME}.to_disk
+tag method +tag method