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
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIClt2EFzdP8qOhRSR2xhLDwqaDdl7Hkwzbz4Yc7Mk4H3 fandi
@nunenuh
nunenuh / public_key
Created April 20, 2023 02:12
public_jey
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJbbRYuF366f0XjqZ8KMJc1K3tQJZg6RVWoPaCFX4qas fandi@tigapilarmandiri.com
@nunenuh
nunenuh / info.md
Created September 27, 2021 08:55
Install PyCuda Ubuntu 20.04
@nunenuh
nunenuh / generate_random_color_image.py
Last active May 27, 2022 10:59
Generate Random Uniform Colored Image with OpenCV
import random
import numpy as np
import matplotlib.pyplot as plt
from tqdm import tqdm, trange
from pathlib import Path
import cv2 as cv
def random_color_image(size=(600,800)):
r = int(np.random.uniform(0,255))
g = int(np.random.uniform(0,255))
# build your model
class StandardMNIST(nn.Module):
def __init__(self):
super().__init__()
# mnist images are (1, 28, 28) (channels, width, height)
self.layer1 = torch.nn.Linear(28 * 28, 128)
self.layer2 = torch.nn.Linear(128, 256)
self.layer3 = torch.nn.Linear(256, 10)
def forward(self, x):
# build your model
class CustomMNIST(LightningModule):
def __init__(self):
super().__init__()
# mnist images are (1, 28, 28) (channels, width, height)
self.layer1 = torch.nn.Linear(28 * 28, 128)
self.layer2 = torch.nn.Linear(128, 256)
self.layer3 = torch.nn.Linear(256, 10)
def forward(self, x):
# import all you need
import os
import torch
import torchvision
import torch.nn as nn
import torch.nn.functional as F
from torch.utils.data import DataLoader, random_split
from torchvision.datasets import MNIST
from torchvision import datasets, transforms
import pytorch_lightning as pl
@nunenuh
nunenuh / custom_model.py
Created July 27, 2020 18:44
PyTorch Lightning Simple Example
# build your model
class CustomMNIST(LightningModule):
def __init__(self):
super().__init__()
# mnist images are (1, 28, 28) (channels, width, height)
self.layer1 = torch.nn.Linear(28 * 28, 128)
self.layer2 = torch.nn.Linear(128, 256)
self.layer3 = torch.nn.Linear(256, 10)
def forward(self, x):
class StandardMNIST(LightningModule):
def __init__(self):
super().__init__()
# mnist images are (1, 28, 28) (channels, width, height)
self.layer1 = torch.nn.Linear(28 * 28, 128)
self.layer2 = torch.nn.Linear(128, 256)
self.layer3 = torch.nn.Linear(256, 10)
def forward(self, x):
batch_size, channels, width, height = x.size()
# Looping Over Collection Forward
colors = ["red", "green", "blue"]
# bad
for i in range(len(colors)):
print(colors[i])
# good
for color in colors:
print(color)