Browse and solve 1,200+ machine learning coding challenges on Deep-ML. Filter by difficulty (beginner, intermediate, advanced) and category (linear algebra, machine learning, deep learning, NLP, computer vision). Write Python solutions in the browser and get instant feedback against test cases.
Write a Python function kernel_function that computes the linear kernel between two input vectors x1 and x2. The linear kernel is defined as the dot product (inner product) of two vectors.
import numpy as np x1 = np.array([1, 2, 3]) x2 = np.array([4, 5, 6]) result = kernel_function(x1, x2) print(result)
32
The linear kernel between x1 and x2 is computed as:1*4 + 2*5 + 3*6 = 32