Vectorization: Must-know Technique to Speed Up Operations 100x Faster
In current data science or machine learning applications, huge datasets and sophisticated networks are usually involved. Thus, code efficiency becomes really important when it comes to handling the computational workload. As an example, in a classic Multi-layer Perceptron (aka Feedforward Neural Network), the network typically contains multiple linear layers. Let's say the input layer contains 64 neurons while the first hidden layer contains 128 hidden neurons. Then, in order to calculate the output of the hidden layer given an input, the straightforward way would be to use the np.dot method provided by the Numpy library: As we can see, this method takes 1.4 microseconds on average.
May-24-2022, 20:15:18 GMT
- Technology: