發表文章

Useful "np.vectorize" function to match arrayfun in Matlab

In Matlab it is convenient to use arrayfun to map the function to a data array. Today I just find it out that we have the analogous one in Python. So if you want to do in Matlab : arrayfun( @(x) x*x, [ 1 : 10 ]) Then you can do it in Python : a = np.arange(1,10) np . vectorize (lambda x: x*x) ,(a ) Alternatively you can do it in R: sapply(seq( 1 , 10 ), function (x){x*x}) But please note that np.vectorize is designed for convenience, not for performance. So essentially you are still doing in a loop which may slow. Also there is one called "np.fromiter". As defined in manual, it is used for "Create a new 1-dimensional array from an iterable object. " iterable = ( x * x for x in range ( 1,10 )) np . fromiter ( iterable , float ) Don't forget the map function which is very useful too. list(map( (lambda x: x*x), a)) Ok, come back to np.vectorize, several Parameters are useful : (1)excluded: Since there may be more that one...

AndrewNg's CNN notes (Neural Style Transfer)

圖片

AndrewNg's CNN notes (Face Recognition)

圖片

AndrewNg's CNN notes (YOLO)

圖片

AndrewNg's CNN notes(classification & localization)

圖片

AndrewNg's CNN notes(practical issues)

圖片
In this example, the author adapted the architecture obtained from training ILSVRC-2011 dataset which consists of 1000 classes with approximately 1.5 million images. And using the pre-trained VGG-16 network, the author fine-tuned the network on PASCAL VOC detection data (20 object classes, and 1 background class) and replaced the original 1000 way classification layer by a randomly initialized 21-way classification layer. Apart from that, the author keep the rest of the CNN architecture remains unchanged. After training of CNN parameters and filter the region proposals based on their IoU value, at the test stage, RCNN uses Selective Search to extract ~300 boxes that likely contain objects and evaluates the ConvNet on each one of them, followed by NMS(non-maximum suppression) within each class.

AndrewNg's CNN notes (1X1 conv1)

圖片
1X1 convolution and its applications (1) & (2) 1 x 1 convolution is also named a Network in Network. You can think it as a dimension reduction technique which can easily generate a deeper network without conventional way of stacking layers via applying bunch of different filters. Here two usages are described. (1) Motivation for inception network, which leads to the construction of much more complex structure of GoogLeNet!  (2) to save the computation cost by first do 1x1 conv (x16) then conv 5x5 with 32 times instead of directly from 28X28X192 to 28X28X32, just consuming 1/10 of time/computation resource(as illustrated in bottom right)