Files
mikoto10032--deeplearning/books/PRML/PRML-master-Python/prml/kernel/kernel.py
T
2026-07-13 13:30:25 +08:00

28 lines
590 B
Python
Executable File

import numpy as np
class Kernel(object):
"""
Base class for kernel function
"""
def _pairwise(self, x, y):
"""
all pairs of x and y
Parameters
----------
x : (sample_size, n_features)
input
y : (sample_size, n_features)
another input
Returns
-------
output : tuple
two array with shape (sample_size, sample_size, n_features)
"""
return (
np.tile(x, (len(y), 1, 1)).transpose(1, 0, 2),
np.tile(y, (len(x), 1, 1))
)