Skip to content

Instantly share code, notes, and snippets.

View victor-iyi's full-sized avatar
🎯
Focusing

Victor I. Afolabi victor-iyi

🎯
Focusing
View GitHub Profile
@victor-iyi
victor-iyi / color-shell.sh
Created November 27, 2018 10:42
Coloring Shell outputs with different presets
#!/usr/bin/sh
########################## Color Codes ##########################
# Reset
Color_Off='\033[0m' # Text Reset
# Regular Colors
Black='\033[0;30m' # Black
Red='\033[0;31m' # Red
Green='\033[0;32m' # Green
@victor-iyi
victor-iyi / vector.py
Last active November 15, 2021 12:46
A light weight vector utility class
from typing import Generic
from typing import Iterable
from typing import TypeVar
# Generic type.
T = TypeVar('T')
class Vector(Generic[T]):
"""A light-weight Vector utility class, used to perform various operations
@victor-iyi
victor-iyi / perfect-number.py
Created April 10, 2018 11:07
A program to determine if a number is a perfect number.
"""
A program to determine if a number is a perfect number.
"""
def is_perfect_number(n):
"""Determines if a given number is a perfect number.
Any number can be perfect number, if the sum of its
positive divisors excluding the number itself is equal
@victor-iyi
victor-iyi / lines-of-code.py
Last active June 5, 2019 20:30
Improved estimation of how many lines of codes are in a project (using recursion)
"""Improved estimation of how many lines of codes are in a project (using recursion)
@author
Victor I. Afolabi
Director of AI, NioCraft, 115Garage.
Email: javafolabi@gmail.com
GitHub: https://github.com/victor-iyiola
@project
File: lines-of-code.py
@victor-iyi
victor-iyi / decorators.py
Created April 10, 2018 11:05
An example showing off function decorators & class decorators
"""
@author Victor I. Afolabi
A.I. Engineer & Software developer
javafolabi@gmail.com
Created on 05 October, 2017 @ 03:35 PM.
Copyright (c) 2017. Victor. All rights reserved.
"""
@victor-iyi
victor-iyi / tree-traversal.py
Created April 10, 2018 11:04
Traversing a nested list to estimate it's shape or dimension
# Shape = 2x3
a = [
[1, 2, 3],
[4, 5, 6]
]
# Shape = 2x3x2
b = [
[[1, 1], [2, 2], [3, 3]],
[[4, 4], [5, 5], [6, 6]]
@victor-iyi
victor-iyi / neural-net-basics-01-03.5.py
Created November 12, 2017 21:20
Neural network Basics: Part One (weight initialization)
W0 = 2 * np.random.random(size=[input_dim, hidden_dim]) - 1
W1 = 2 * np.random.random(size=[hidden_dim, output_dim]) - 1
@victor-iyi
victor-iyi / neural-net-basics-01-03.5.py
Created November 12, 2017 21:20
Neural network Basics: Part One (weight initialization)
W0 = 2 * np.random.random(size=[input_dim, hidden_dim]) - 1
W1 = 2 * np.random.random(size=[hidden_dim, output_dim]) - 1
@victor-iyi
victor-iyi / neural-net-basics-01-05.py
Last active November 12, 2017 20:38
Neural network Basics: Part One (training)
for i in range(10000):
# Forward propagte our input to get a prediction
l1 = sigmoid(np.dot(X, W0))
l2 = sigmoid(np.dot(l1, W1))
# Estimate how much we missed
l2_error = (y - l2) ** 2
l2_delta = l2_error * sigmoid(l2, prime=True)
# Back propagate error in layer 2 into layer 1
@victor-iyi
victor-iyi / neural-net-basics-01-04.py
Created November 12, 2017 20:28
Neural Network Basics: Part One (Sigmoid function)
def sigmoid(Z, prime=False):
if prime:
return Z * (1 - Z)
return 1 / (1 + np.exp(-Z))