assignment1_colab/assignment1/cs231n/classifiers/k_nearest_neighbor.py
def compute_distances_two_loops(self, X):
        """
        Compute the distance between each test point in X and each training point
        in self.X_train using a nested loop over both the training data and the
        test data.

        Inputs:
        - X: A numpy array of shape (num_test, D) containing test data.

        Returns:
        - dists: A numpy array of shape (num_test, num_train) where dists[i, j]
          is the Euclidean distance between the ith test point and the jth training
          point.
        """
        num_test = X.shape[0]
        num_train = self.X_train.shape[0]
        dists = np.zeros((num_test, num_train))
        for i in range(num_test):
            for j in range(num_train):
                #####################################################################
                # TODO:                                                             #
                # Compute the l2 distance between the ith test point and the jth    #
                # training point, and store the result in dists[i, j]. You should   #
                # not use a loop over dimension, nor use np.linalg.norm().          #
                #####################################################################
                # *****START OF YOUR CODE (DO NOT DELETE/MODIFY THIS LINE)*****

                pass

                # *****END OF YOUR CODE (DO NOT DELETE/MODIFY THIS LINE)*****
        return dists

        Compute the distance between each test point in X and each training point
        in self.X_train using a nested loop over both the training data and the
        test data.

        Inputs:
        - X: A numpy array of shape (num_test, D) containing test data.

        Returns:
        - dists: A numpy array of shape (num_test, num_train) where dists[i, j]
          is the Euclidean distance between the ith test point and the jth training
          point.
        
Compute the distance between each test point in X and each training point
in self.X_train using a nested loop over both the training data and the
test data.

A numpy array of shape (num_test, D) containing test data.
Compute the distance between each test point in X and each training point in self . X_train using a nested loop over both the training data and the test data . A numpy array of shape ( num_test D ) containing test data .
def compute_distances_two_loops(self, X):
        num_test = X.shape[0]
        num_train = self.X_train.shape[0]
        dists = np.zeros((num_test, num_train))
        for i in range(num_test):
            for j in range(num_train):
                pass
        return dists
def compute_distances_two_loops ( self , X ) : num_test = X . shape [ 0 ] num_train = self . X_train . shape [ 0 ] dists = np . zeros ( ( num_test , num_train ) ) for i in range ( num_test ) : for j in range ( num_train ) : pass return dists
Compute the distance between each test point in X and each training point
in self.X_train using a nested loop over both the training data and the
test data.
Compute the distance between each test point in X and each training point in self . X_train using a nested loop over both the training data and the test data .
"""
        Compute the distance between each test point in X and each training point
        in self.X_train using a nested loop over both the training data and the
        test data.

        Inputs:
        - X: A numpy array of shape (num_test, D) containing test data.

        Returns:
        - dists: A numpy array of shape (num_test, num_train) where dists[i, j]
          is the Euclidean distance between the ith test point and the jth training
          point.
        """ ##################################################################### # TODO:                                                             # # Compute the l2 distance between the ith test point and the jth    # # training point, and store the result in dists[i, j]. You should   # # not use a loop over dimension, nor use np.linalg.norm().          # ##################################################################### # *****START OF YOUR CODE (DO NOT DELETE/MODIFY THIS LINE)***** # *****END OF YOUR CODE (DO NOT DELETE/MODIFY THIS LINE)*****
None
self
X