Skip to content

Instantly share code, notes, and snippets.

View nunenuh's full-sized avatar
🏠
Working remotely from home

Lalu Erfandi Maula Yusnu nunenuh

🏠
Working remotely from home
View GitHub Profile
# Looping Over Collection with Indice Forward
colors = ["red", "green", "blue"]
# bad
for i in range(len(colors)):
print(i,'--',colors[i])
# good
for i, color in enumerate(colors):
print(i, '--', color)
# Looping Over Two Collection
names = ["raymond", "rachel","matthew"]
colors = ["red", "green", "blue"]
# bad
n = min(len(names), len(colors))
for i in range(n):
print(names[i], '--', colors[i])
# good
# Looping Over Collection Backward
colors = ["red", "green", "blue"]
# bad
for i in range(len(colors)-1, -1, -1):
print(colors[i])
# good
for color in reversed(colors):
print(color)
import sys
####################
### Set the hyperparameters in you myanswers.py file ###
####################
from my_answers import iterations, learning_rate, hidden_nodes, output_nodes
N_i = train_features.shape[1]
network = NeuralNetwork(N_i, hidden_nodes, output_nodes, learning_rate)
@nunenuh
nunenuh / NeuralNetwork.py
Created April 14, 2019 07:33
Neuralnetwork udacity
import numpy as np
class NeuralNetwork(object):
def __init__(self, input_nodes, hidden_nodes, output_nodes, learning_rate):
# Set number of nodes in input, hidden and output layers.
self.input_nodes = input_nodes
self.hidden_nodes = hidden_nodes
self.output_nodes = output_nodes
import random
import torch
import pathlib
import os
from torch.utils import data
import PIL
import PIL.Image
class SiameseDataset(data.Dataset):
def __init__(self, root, ext, transform=None, pair_transform=None, target_transform=None):
@nunenuh
nunenuh / crop_for_zali.py
Created July 30, 2018 00:55
opencv webcam record
import numpy as np
import cv2
x1, x2 = 100,400
y1, y2 = 10, 310
cap = cv2.VideoCapture(0)
while(True):
ret, frame = cap.read()
r = cv2.rectangle(frame,(y1,x2),(y2,x1),(0,255,0),3)
crop = frame[x1:x2, y1:y2]
@nunenuh
nunenuh / autocrop_center.py
Created July 16, 2018 18:43
AutoCrop center
import numpy as np
import cv2
def center_rectangle(frame):
h,w,d = frame.shape
x1,y1 = h//4, w//4
x2,y2 = h-x1, w-y1
rr = cv2.rectangle(frame,(y1,x1),(y2,x2),(0,255,0),3)
crop = frame[x1:x2, y1:y2]
return rr
@nunenuh
nunenuh / mogrify_rescale.py
Created June 3, 2018 16:19
Mogrify Rescale with python automate
import os
base_path = '/home/nunenuh/Desktop/skripsi/dataset/testing'
def rescale(base_path,percent):
dirz = os.listdir(base_path)
my_list = []
for dr in dirz:
path = os.path.join(base_path, dr,'*.jpg')
my_list.append(path)
@nunenuh
nunenuh / tone_generator.py
Last active May 15, 2018 00:45
Generating tone based on Factor 9 built on 432
from pysine import sine
import numpy as np
def genfreq(num):
tone = []
lbfreq = [126, 135, 144, 153, 162, 171, 180,
189, 198, 207, 216, 225, 234, 243]
lbfreq = np.array(lbfreq)
for i in range(0, num):
val = lbfreq * (2**i)