Run this notebook online:\ |Binder| or Colab: |Colab| .. |Binder| image:: https://mybinder.org/badge_logo.svg :target: https://mybinder.org/v2/gh/deepjavalibrary/d2l-java/master?filepath=chapter_preliminaries/lookup-api.ipynb .. |Colab| image:: https://colab.research.google.com/assets/colab-badge.svg :target: https://colab.research.google.com/github/deepjavalibrary/d2l-java/blob/colab/chapter_preliminaries/lookup-api.ipynb Documentation ============= Due to constraints on the length of this book, we cannot possibly introduce every single DJL function and class (and you probably would not want us to). The API documentation and additional tutorials and examples provide plenty of documentation beyond the book. In this section we provide you with some guidance to exploring the DJL API. Finding All the Functions and Classes in a Module ------------------------------------------------- In order to know which functions and classes can be called, we can go to the javadocs for DJL which can be seen here: https://javadoc.io/doc/ai.djl/api/latest/index.html There we can search for the class that we are interested in exploring. For instance, we can go to the ``All Classes`` box on the left and search for ``NDManager``. In this class you will see all the functions that can be called and any information or documentation regarding them. https://javadoc.io/doc/ai.djl/api/latest/ai/djl/ndarray/NDManager.html To explore an example, if we were interested in functions that handled generating ``NDArray``\ s with random numbers, we could search for the functions that start with ``random`` or that contain ``random`` in their description. By doing this, we can see that there are a few functions that actually do what we want. To mention a few: - randomInteger(long low, long high, Shape shape, DataType dataType) - randomMultinomial(int n, NDArray pValues) - randomMultinomial(int n, NDArray pValues, Shape shape) - randomNormal(float loc, float scale, Shape shape, DataType dataType) - randomUniform(float low, float high, Shape shape) Finding the Usage of Specific Functions and Classes --------------------------------------------------- For more specific instructions on how to use a given function or class, we can click the desired function or go to it directly by scrolling down and searching for it. As an example, let us explore the usage instructions for ``NDManager``'s ``ones`` function which takes a ``Shape`` as a parameter. https://javadoc.io/static/ai.djl/api/0.20.0/ai/djl/ndarray/NDManager.html#ones(ai.djl.ndarray.types.Shape) From the documentation, we can see that the ``ones`` function creates a new ``NDArray`` with the specified shape and sets all the elements to the value of 1. Whenever possible, you should run a quick test to confirm your interpretation: .. code:: java %load ../utils/djl-imports .. code:: java NDManager manager = NDManager.newBaseManager(); manager.ones(new Shape(4)) .. parsed-literal:: :class: output ND: (4) gpu(0) float32 [1., 1., 1., 1.] Summary ------- - The official documentation provides plenty of descriptions and examples that are beyond this book. - We can look up documentation for the usage of an API by accessing the javadoc directly. Exercises --------- 1. Look up the documentation for any function or class in the deep learning framework MXNet. Can you also find the documentation on the official DJL website?