facebookarchive / caffe2

Caffe2 is a lightweight, modular, and scalable deep learning framework.
https://caffe2.ai
Apache License 2.0
8.42k stars 1.95k forks source link

Index the operators catalogue with logic groups #415

Open futurely opened 7 years ago

futurely commented 7 years ago

Alphabetically https://caffe2.ai/docs/operators-catalogue.html

Indexed http://mxnet.io/api/python/symbol.html

aaronmarkham commented 7 years ago

Hi @futurely, we recently added an index to the top that should help a bit.

One thought we've had on this is to add "category" to the operator's schema's.

Take for instance this softmax operator and the schema code below. We have an internal script that parses these fields to automatically generate the operators-catalogue.md file:

OPERATOR_SCHEMA(HSoftmax)
  .NumInputs(4)
  .NumOutputs(2)
  .SetDoc(R"DOC(
Hierarchical softmax is an operator which approximates the softmax operator
while giving significant training speed gains and reasonably comparable
performance. In this operator, instead of calculating the probabilities of all
the classes, we calculate the probability of each step in the path from root to
the target word in the hierarchy.
The operator takes a 2-D tensor (Tensor<float>) containing a batch of layers, a
set of parameters represented by the weight matrix and bias terms, and a 1-D
tensor (Tensor<int>) holding labels, or the indices of the target class. The
hierarchy has to be specified as an argument to the operator.
The operator returns a 1-D tensor holding the computed log probability of the
target class and a 2-D tensor of intermediate outputs (from the weight matrix
and softmax from each step in the path from root to target class) which will be
used by the gradient operator to compute gradients for all samples in the batch.
)DOC")
  .Arg("hierarchy", "Serialized HierarchyProto string containing list of "
  "vocabulary words and their paths from root of hierarchy to the leaf")
  .Input(0, "X", "Input data from previous layer")
  .Input(1, "W", "2D blob containing 'stacked' fully connected weight "
  "matrices. Each node in the hierarchy contributes one FC weight matrix if "
  "it has children nodes. Dimension is N*D, D is input dimension of data (X), "
  "N is sum of all output dimensions, or total number of nodes (excl root)")
  .Input(2, "b", "1D blob with N parameters")
  .Input(3, "labels", "int word_id of the target word")
  .Output(0, "Y", "1-D of log probability outputs, one per sample")
  .Output(1, "intermediate_output", "Extra blob to store the intermediate "
  "FC and softmax outputs for each node in the hierarchical path of a word. "
  "The outputs from samples are stored in consecutive blocks in the forward "
  "pass and are used in reverse order in the backward gradientOp pass");

It would be possible to add to this specification a ".Category" field where you specify one or more categories that the operator belongs to. For example:

  .Category("math")

Or maybe if it belonged to two categories:

  .Category("math", "symbol")

Then the operators-catalogue.md file can have a navigation that uses the categories. Other ideas?

futurely commented 7 years ago

I noticed the newly added index. Automatically generating the categories navigation is a good idea. Thanks!