Dynet api tutorial#1312
Conversation
|
@xunzhang Please take a look of what has been modified so far. I think I will continue working on part 4 and 5 later this week. |
|
Sure. This is great! |
|
This is very cool. I have one remark: the API for parameters was changed recently (you don't need to call |
|
@pmichel31415 Agree, I think this can be finished before early next week, let's make a release when we finish this. And refactor existing models with the new interface. Further implementations should base on new interfaces. FYI, @zhechenyan please apple changes from #1233 to your |
| "from __future__ import division\n", | ||
| "from __future__ import absolute_import\n", | ||
| "\n", | ||
| "import dynet_config\n", |
There was a problem hiding this comment.
Add a comment that says please import dynet_config before import dynet, this is important to know.
There was a problem hiding this comment.
| "metadata": {}, | ||
| "source": [ | ||
| "#### Create Parameters\n", | ||
| "Parameters are things that are optimized. in contrast to a system like Torch where computational modules may have their own parameters, in DyNet parameters are just parameters." |
There was a problem hiding this comment.
in -> In. systems like Tensorflow and Torch.
| "b = dy.parameter(pb)\n", | ||
| "\n", | ||
| "m = dy.ParameterCollection() \n", | ||
| "W = m.add_parameters((8,8)) # an 8x8 matrix\n", |
There was a problem hiding this comment.
add a comment that says add_parameters return an expr.
| "p = m.add_parameters((3,5), init=dy.PyInitializer()) # Any parameter initializer\n", | ||
| "scale = 1\n", | ||
| "mean = 0\n", | ||
| "stddev = 1\n", |
There was a problem hiding this comment.
merge these three into one line please.
| "p = m.add_parameters((3,5), init='he')\n", | ||
| "# Creates 3x5 matrix from a numpy array (size is inferred)\n", | ||
| "p = m.add_parameters((3,5), np.ones((3,5)))\n", | ||
| "# Creates 3x5 matrix from a numpy array (size is inferred)" |
There was a problem hiding this comment.
remove this line please.
| "# initialize LookupParameters.\n", | ||
| "scale = 1\n", | ||
| "mean = 0\n", | ||
| "stddev = 1\n", |
| "cell_type": "markdown", | ||
| "metadata": {}, | ||
| "source": [ | ||
| "#### Expression Manipulation\n", |
There was a problem hiding this comment.
rename as More Expression Manipulation?
|
Just finished review above the |
|
@zhechenyan @xunzhang Is this ready for a final check? |
|
@neubig not yet. I'll let you know when it's ready for a final look. Probably this weekend. |
|
cc @neubig , please take a final review and do merge please. |
neubig
left a comment
There was a problem hiding this comment.
Overall, looks good! I have a few comments, and also think this needs a spell check. Once that's done I think we can merge.
| "outputs": [], | ||
| "source": [ | ||
| "# create a vector/matrix expression of special values\n", | ||
| "# Different from TensorFlow, DyNet treats batch as the last dim\n", |
There was a problem hiding this comment.
This is not exactly correct. DyNet has a special "batch" dimension, so that you don't need to think about the batch dimension most of the time other than during input and output. Could we make this a little more accurate, following the explanation here?:
http://dynet.readthedocs.io/en/latest/minibatch.html
| "dim = 5\n", | ||
| "batch_size = 3\n", | ||
| "e = dy.zeros(dim, batch_size=batch_size)\n", | ||
| "print('zeors of dim {} and batch_size {}:\\n{}'.format(dim, batch_size, e.npvalue()))\n", |
| "cell_type": "markdown", | ||
| "metadata": {}, | ||
| "source": [ | ||
| "It should be noticed that in DyNet 2.0+ and later version, the dy.parameters() is depecated so explicitly adding parameters to the computation graph is no longer necessary. Any used parameter will be added automatically." |
There was a problem hiding this comment.
It should be noticed that in DyNet 2.0+ and later version, the dy.parameters() is depecated
->
Previously, it was necessary to add parameters to the computation graph using "dy.parameters()", but this is now deprecated
There was a problem hiding this comment.
Also it should probably be 2.0.4+ or ">2.0.3"so that people don't get confused
| "metadata": {}, | ||
| "outputs": [], | ||
| "source": [ | ||
| "# Ceate expressions from lookup parameters.\n", |
There was a problem hiding this comment.
Ceate -> Create
(There may be other spelling errors, so I'd try to spell-check the text)
| "metadata": {}, | ||
| "source": [ | ||
| "#### More Expression Manipulation\n", | ||
| "DyNet provides hundreds of operations on Expression. User can manipulate Expressions, build complex Expression easily." |
There was a problem hiding this comment.
operations on Expression -> operations that can be applied to Expressions
User -> The user
build complex Expression -> and build complex Expressions
|
Hi! There are a few small comments here, but I think this is largely good. Do you think you could finish this up? |
|
cc @zhechenyan |
|
Sure I will finish this by the end of the weekend. |
|
Ping? |
|
Ping x2 |
|
Made a few changes and merged! |
Rewritten the API tutorial (#1302) so that user can have a better idea on how to use DyNet masterfully.
This includes: