Algorithms | Learn for Master
  • Good articles to learn Convolution Neural Networks

    Understanding Convolutions


    neural networks, convolutional neural networks, convolution, math, probability

    In a previous post, we built up an understanding of convolutional neural networks, without referring to any significant mathematics. To go further, however, we need to understand convolutions.

    If we just wanted to understand convolutional neural networks, it might suffice to roughly understand convolutions. But the aim of this series is to bring us to the frontier of convolutional neural networks and explore new options.

    [Read More...]
  • Good resources to learn VC dimension

    Machine f can shatter a set of points x1 , x2 .. Xr if and only if… For every possible training set of the form (x1 ,y1 ) , (x2 ,y2 ) ,… (xr ,yr ) …There exists some value of a that gets zero training error.

    Given machine f, the VC-dimension h is The maximum number of points that can be arranged so that f shatter them

    For 2-d inputs, what’s VC-dim of f(x,w,b) = sign(w.x+b)? Well, can we find four points that f can shatter? Can always draw six lines between pairs of four points.

    [Read More...]
  • Calling an external command in Python

    How can I call an external command (as if I’d typed it at the Unix shell or Windows command prompt) from within a Python script?

    [Read More...]
  • Hive Case statement examples

    A CASE expression returns a value from the THEN portion of the clause. You could use it thusly:

    Note that you need to do something with the returned value, e.g. compare it to 1. Your statement attempted to return the value of an assignment or test for equality, neither of which make sense in the context of a CASE/THEN clause. (If BOOLEAN was a datatype then the test for equality would make sense.)


    [Read More...]
  • [LeetCode] Android Unlock Patterns

    Given an Android 3×3 key lock screen and two integers m and n, where 1 ≤ m ≤ n ≤ 9, count the total number of unlock patterns of the Android lock screen, which consist of minimum of m keys and maximum n keys.

    Rules for a valid pattern:

    1. Each pattern must connect at least m keys and at most n keys.
    2. All the keys must be distinct.
    3. If the line connecting two consecutive keys in the pattern passes through any other keys, the other keys must have previously selected in the pattern.
    [Read More...]
  • Find median of a infinite stream of integers

    Median of a stream of numbers

    Given a stream of integers, find the median of the stream of numbers received so far. 

    Median is the middle value in an ordered integer list. If the size of the list is even, there is no middle value. So the median is the mean of the two middle value.

    Median of stream of numbers can be queried at multiple times at different point of time. Insertion and median functions can be called in any order. For example:

    First solution be to store the stream received in an unsorted array.

    [Read More...]
  • [Leetcode] Fraction to Recurring Decimal

    Given two integers representing the numerator and denominator of a fraction, return the fraction in string format.

    If the fractional part is repeating, enclose the repeating part in parentheses.

    For example,

    • Given numerator = 1, denominator = 2, return “0.5”.
    • Given numerator = 2, denominator = 1, return “2”.
    • Given numerator = 2, denominator = 3, return “0.(6)”.


    1. No scary math, just apply elementary math knowledge. Still remember how to perform a long division?
    2. Try a long division on 4/9,
    [Read More...]
  • Ones and Zeroes

    474. Ones and Zeroes

    In the computer world, use restricted resource you have to generate maximum benefit is what we always want to pursue.

    For now, suppose you are a dominator of m0s and n1s respectively. On the other hand, there is an array with strings consisting of only 0sand 1s.

    Now your task is to find the maximum number of strings that you can form with given m0s and n1s. Each 0 and 1 can be used at mostonce.


    1. The given numbers of 0s and 1s will both not exceed 100
    2. The size of given string array won’t exceed 600.
    [Read More...]
  • Darts, Dice, and Coins: Sampling from a Discrete Distribution

    Darts, Dice, and Coins: Sampling from a Discrete Distribution

    Earlier this year, I asked a question on Stack Overflow about a data structure for loaded dice. Specifically, I was interested in answering this question:

    “You are given an n-sided die where side i has probability pi of being rolled. What is the most efficient data structure for simulating rolls of the die?”

    This data structure could be used for many purposes. For starters, you could use it to simulate rolls of a fair, six-sided die by assigning probability 1616 to each of the sides of the die,

    [Read More...]
  • The Alias Method for weighted sampling

    The Alias Method

    The previous technique has excellent best-case behavior, generating a random roll using a single fair die roll and coin flip. On expectation, its worst-case behavior is much worse, though, potentially requiring a linear number of die rolls and coin flips. The reason for this is that, unlike the previous techniques, the algorithm may “miss” and have to repeatedly iterate until it decides on a decision. Graphically, this is because it works by throwing darts at a target that may contain a large amount of empty space not assigned to any outcome. If there were a way to eliminate all of that empty space such that every piece of the target was covered by a rectangle corresponding to some side of the loaded die,

    [Read More...]
Page 1 of 812345...Last »