Skip to content

Instantly share code, notes, and snippets.

@dantp-ai
dantp-ai / 2d_convolution.py
Last active March 18, 2023 14:35
2d convolution for stride of one with same output shape
import numpy as np
def convolve2D_same_output_shape(input_volume, kernel):
kernel = np.flipud(np.fliplr(kernel))
kernel_height = kernel.shape[0]
kernel_width = kernel.shape[1]
input_height = input_volume.shape[0]
@dantp-ai
dantp-ai / delete_all_local_brances_except_master_and_develop.sh
Created October 14, 2021 09:29
delete_all_local_brances_except_master_and_develop.sh
git branch | grep -v "master\|develop" | xargs git branch -D
d5ae8e68696c00ad53ce60d984e8370d0c1e7b2e45df57530eb4f8596868fce1 ProtonVPN_mac_v2.1.0.dmg
@dantp-ai
dantp-ai / example_google.py
Last active May 21, 2021 08:30
Google Style Docstrings for Python and Numpy
# -*- coding: utf-8 -*-
"""Example Google style docstrings.
This module demonstrates documentation as specified by the `Google Python
Style Guide`_. Docstrings may extend over multiple lines. Sections are created
with a section header and a colon followed by a block of indented text.
Example:
Examples can be given using either the ``Example`` or ``Examples``
sections. Sections support any reStructuredText formatting, including
@dantp-ai
dantp-ai / simple_seed_test.py
Last active October 31, 2020 21:06
A simple test showing that for the same random seed, code, and neural network weight initialization, the updated weights are the same (PyTorch, v1.6.0)
import torch
import torch.nn as nn
from copy import deepcopy
def trial(seed):
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
torch.manual_seed(seed)
input_size = 4
output_size = 1
step_size = 0.005