Skip to content

Instantly share code, notes, and snippets.

@neodelphis
neodelphis / conv_forward_naive.py
Created Jul 17, 2019
A naive implementation of the forward pass for a convolutional layer.
View conv_forward_naive.py
def conv_forward_naive(x, w, b, conv_param):
"""
A naive implementation of the forward pass for a convolutional layer.
The input consists of N data points, each with C channels, height H and
width W. We convolve each input with F different filters, where each filter
spans all C channels and has height HH and width WW.
Input:
- x: Input data of shape (N, C, H, W)
@neodelphis
neodelphis / conv_backward_naive.py
Last active May 31, 2021
Backprop in a conv layer
View conv_backward_naive.py
def conv_backward_naive(dout, cache):
"""
A naive implementation of the backward pass for a convolutional layer.
Inputs:
- dout: Upstream derivatives.
- cache: A tuple of (x, w, b, conv_param) as in conv_forward_naive
Returns a tuple of:
- dx: Gradient with respect to x
@goldsborough
goldsborough / conv.cu
Last active May 16, 2021
Convolution with cuDNN
View conv.cu
#include <cudnn.h>
#include <cassert>
#include <cstdlib>
#include <iostream>
#include <opencv2/opencv.hpp>
#define checkCUDNN(expression) \
{ \
cudnnStatus_t status = (expression); \
if (status != CUDNN_STATUS_SUCCESS) { \