I know we already have some docs for the FastAI methods. But some of the methods manage to drive me spinning eternally.
So one of my suggestion is to document, whenever possible, at least the two pieces of information in all relevant methods:
- Type of the collection being passed: Numpy array OR PyTorch Tensor
- Shape if numpy.array, and size. if Pytorch.Tensor
In trying to develop and/or understand any neural-network architecture, knowing exactly the shape (size) of tensors being passed around have always helped me crucially. Much of the other integer/string parameters are simple to understand. The collections, on the other hand, can get really confusing with operation such as:
np.tile(np.stack(np.linspace(0,5,0.1)[-1, :3, :-2], tensor_no_idea_what_shape))
Take for example, a method from pascal-multi.ipynb:
def actn_to_bb(actn, anchors): actn_bbs = torch.tanh(actn) actn_centers = (actn_bbs[:,:2]/2 * grid_sizes) + anchors[:,:2] actn_hw = (actn_bbs[:,2:]/2+1) * anchors[:,2:] return hw2corners(actn_centers, actn_hw)
If this method is moved into a library python class, then it’d be really hard to know what this method was doing, without knowing, for instance (I don’t really know what they are, so kind of illustrating to the point) that
- anchors was a numpy array of shape (num_x_grids, num_y_grids)
- actn was a tensor of shape (batch_size, num_classes)
@jeremy I realize that it is easy to just instruct, and I apologize for that, but I think adding the two pieces of information for every method that you introduce will be a BIG help to everyone. I think it’s just a really good documentation model, and just doing so going forward would set a great precedence for all documentation forthcoming.
Thanks … and I do genuinely appreciate the course material.