發表文章

目前顯示的是 2月, 2018的文章

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)

AndrewNg's CNN notes (example of Nets)

圖片
Virtual Geometry Group & 16-layered

AndrewNg's CNN notes (convolution)

圖片

AndrewNg's CNN notes (edge detection)

圖片

Gift

Yesterday, I checked my son's exercise book and it really gave me a big surprise.  We sent he to attend a tuition class and then seems we forget all our responsibility for his English grammar. The exercise book now he is working is on the second book he got, he finished one before, and the tuition teacher give him the second one just to repeat. But i found he still has average 4~5 incorrect answers per 10 questions.  Oh my god, it is time to intervene myself now!! It lets me think over and over the question: As parent, what can you give to your child as the best gift (apart from the material stuff) and how? Knowledge? Skills? Tips? Experience?

CNN notes

圖片

Hough transformation

圖片
The linear Hough transform  algorithm  uses a two-dimensional array, called an accumulator, to detect the existence of a line described by  {\displaystyle r=x\cos \theta +y\sin \theta } . The  dimension  of the accumulator equals the number of unknown parameters, i.e., two, considering quantized values of r and θ in the pair (r,θ). For each pixel at  (x,y)  and its neighborhood, the Hough transform algorithm determines if there is enough evidence of a straight line at that pixel. If so, it will calculate the parameters (r,θ) of that line, and then look for the accumulator's bin that the parameters fall into, and increment the value of that bin. By finding the bins with the highest values, typically by looking for local maxima in the accumulator space, the most likely lines can be extracted, and their (approximate) geometric definitions read off.(Wiki)

Canny Edge detection

圖片
1, Filter out noise using Gaussian filter. 2, Find intensity gradient of image (horizontal dimension & vertical dimension Gx, Gy) 3, Non-maximum suppression is applied.

Image segmentation

image segmentation : The image segmentation approaches can be categorized into two types based on properties of image. A. Discontinuity detection based approach: B.Similarity detection based approach: Similarity detection is an approach which is based on finding the similar region of an image. The following are the techniques that come under this are: region growing, thresholding techniques and region merging and splitting. All these techniques divide an image with the help of similar pixels. This approach is also used for clustering the data. In this approach, clusters of pixels are formed that have similar features. So image segmentation has mainly three perspective approaches. These are: 1. Region Approach: This falls under similarity detection approach. 2. Edge detection and Data Clustering Approach: Edge detection approach comes under discontinuity detection approach but data clustering comes similarity detection based approach. A. Thresholding Method B. Edge Bas...

image processing

1. Ostu’s method for automatic thresholding to get binary images(to maximize the between-class variance) 2. Hough Transform to find lines in images 3. Motion based Segmentation using Accumulative Difference Image

RCNN

From <<Rich feature hierarchies for accurate object detection and semantic segmentation>>: CNNs saw heavy use in the 1990s, but then fell out of fashion with the rise of support vector machines.  In 2012, Krizhevsky rekindled interest in CNNs by showing substantially higher image classification accuracy on the ImageNet Large Scale Visual Recognition Challenge (ILSVRC) . Their success resulted from training a large CNN on 1.2 million labeled images, together with a few twists on LeCun’s CNN (e.g., max(x, 0) rectifying non-linearities and “dropout” regularization) Instead, we solve the CNN localization problem by operating within the recognition using regions paradigm, which has been successful for both object detection and semantic segmentation. At test time, our method generates around 2000 category-independent region proposals for the input image, extracts a fixed-length feature vector from each proposal using a CNN, and then classifies each region with categor...

mAP: reflesh

圖片
Assume that we want to estimate an unobserved population parameter  {\displaystyle \theta }  on the basis of observations  {\displaystyle x} . Let  {\displaystyle f}  be the  sampling distribution  of  {\displaystyle x} , so that  {\displaystyle f(x\mid \theta )}  is the probability of  {\displaystyle x}  when the underlying population parameter is  {\displaystyle \theta } . Then the function: {\displaystyle \theta \mapsto f(x\mid \theta )\!} is known as the  likelihood function  and the estimate: {\displaystyle {\hat {\theta }}_{\mathrm {ML} }(x)={\underset {\theta }{\operatorname {arg\,max} }}\ f(x\mid \theta )\!} is the maximum likelihood estimate of  {\displaystyle \theta } . Now assume that a  prior distribution   {\displaystyle g}  over  {\displaystyle \theta }  exists. This allows us to treat  {\displaystyle \theta }  as a  random variable  as in...