Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added documentation #26

Merged
merged 5 commits into from
Jul 29, 2018
Merged

Added documentation #26

merged 5 commits into from
Jul 29, 2018

Conversation

anshuman23
Copy link
Owner

@josevalim I have added documentation using ExDoc. Please let me know what all changes you think are required before I merge this.

Next I will clean up the README.

@josevalim
Copy link
Contributor

@anshuman23 we should not add the doc/ folder. Make sure it is in your .gitignore. :)

- Since Tensorflex provides Inference capability for pre-trained graph models, it is assumed you have adequate knowledge of the pre-trained models you are using (such as the input data type/dimensions, input and output operation names, etc.). Some basic understanding of the [Tensorflow Python API](https://www.tensorflow.org/api_docs/python/) can come in very handy.

- Tensorflex consists of multiple NIFs, so exercise caution while using it-- providing incorrect operation names for running sessions, incorrect dimensions of tensors than the actual pre-trained graph requires, providing different tensor datatypes than the ones required by the graph can all lead to failure. While these are not easy errors to make, do ensure that you test your solution well before deployment.
"""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we wrap this and all docs below around 80-100 columns?

Otherwise reading them becomes a bit hard. :)

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I apologize, I should have done that before committing. I've wrapped all the doc text to 80 columns now :)

@@ -1,5 +1,6 @@
defmodule Tensorflex.Tensor do

@moduledoc false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this should be public given that we return it in many examples?

Copy link
Owner Author

@anshuman23 anshuman23 Jul 29, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that might be counter-intuitive. Since the structs mainly handle the NIF references, I don't think it would be appropriate for users to know about the internal working of the Tensorflex structs. Adding docs for the internal structs might make users think that they can also modify/work with them. Plus there is no code to really document, just the reference wrapping struct.

This is my take on it. What do you think?

PS: I'm merging this PR for now, but in case you think that we should have docs for the structs, I will put in a new PR for them

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the best is to implement Inspect protocol for this to return something opaque. Something like this after the module definition:

defimpl Inspect, for: Tensorflex.Tensor do
  def inspect(data, _opts) do
    "#Tensorflex.Tensor<#{data.datatype}>"
  end
end

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be the best thing to do. I'll add this code to all these side modules in the next PR. Thank you!

Generally to check that the loaded graph model is correct and contains computational operations, the `get_graph_ops/1` function is useful:
```elixir
iex(2)> Tensorflex.get_graph_ops graph
["DecodeJpeg/contents", "DecodeJpeg", "Cast", "ExpandDims/dim", "ExpandDims",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn we indent this result in the same way IEx idents it when printing to the shell?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is indented in exactly the same way the IEx prints the output to shell. I have copied these outputs from there, after running their commands

@josevalim
Copy link
Contributor

Thanks @anshuman23! I have added some comments, some are aesthetic ones, but generally this looks great!

different tensor datatypes than the ones required by the graph can all lead to
failure. While these are not easy errors to make, do ensure that you test your
solution well before deployment.
"""
Copy link
Contributor

@josevalim josevalim Jul 29, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The standard in Elixir is to keep all of the contents inside the heredoc indented. SOmething like this:

defmodule Foo do
  @moduledoc """
  Foo bar is a very long line
  that is meant to work as example:

    * this is a bullet that spans more
      than one line
  """

  def bar do

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright I see. This would look better and be more readable.

Would it be possible to share what tool/editor you use for doing this? I use Vim and/or Emacs and I am not sure how to do this using either of them. I used Vim for currently wrapping the text to the 80 column limit.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@josevalim I have made the IEx indentation changes. This is the only change remaining. How can I fix this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I use sublime text 3 but it doesn't do auto formatting. It does help me keep the proper indention though.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fixed this so the indentation reads well now

"conv_2/control_dependency", "conv_2", "pool/CheckNumerics",
"pool/control_dependency", "pool", "conv_3/conv2d_params", "conv_3/Conv2D",
"conv_3/batchnorm/beta", "conv_3/batchnorm/gamma",
"conv_3/batchnorm/moving_mean", "conv_3/batchnorm/moving_variance", ...]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think when pasting the code here you lost the indentation. Here are the examples above from my IEx shell:

screen shot 2018-07-29 at 18 08 59

screen shot 2018-07-29 at 18 07 53

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

This screenshot is from the generated html doc from the current code itself. To me, the output looks exactly similar to the output image you uploaded. I hope I am not misunderstanding what you're saying.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@anshuman23 you can see that all lines in my example are indented by one, according to the list start.

But this is minor, the biggest issue is the struct example I posted above. Where the struct elements should be indented by at least two spaces.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. I'm sorry I didn't notice the indentation-- I thought there was something wrong with the way the text was presented. I think you are right, copying from the shell probably led to a loss in the formatting.

I will fix this right away. Thanks for noticing this problem! :)

@anshuman23
Copy link
Owner Author

@josevalim this is somewhat unrelated, but I had also modified the README directly to read well directly using Github markdown editor. Please let me know if you find something amiss from there as well.

@josevalim
Copy link
Contributor

Don't forget to add doc/ to `.gitignore and remove the files from the commit before merging. :)

@anshuman23 anshuman23 merged commit 0e5bba2 into master Jul 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants