Skip to content

Instantly share code, notes, and snippets.

View umitkacar's full-sized avatar

Umit Kacar, PhD umitkacar

View GitHub Profile
class A:
out1 = 2
out2 = 3
out3 = 4
a = {}
for i in range(1,4):
a[f'out{i}'] = getattr(A,f'out{i}')
print(a)
import numpy as np
x = [6,7,8]
y = np.expand_dims(x, axis=0)
my = [1,2,3]
mx = [4,5,6]
yx = np.tensordot(my,mx,0)
res = np.where(yx == 1)
if not os.path.exists("output"):
os.makedirs("output")
class Address:
def __init__(self, street, city, state, zipcode, street2=''):
self.street = street
self.street2 = street2
self.city = city
self.state = state
self.zipcode = zipcode
def __str__(self):
lines = [self.street]
# use of class method and static method.
from datetime import date
class Person:
def __init__(self, name, age):
self.name = name
self.age = age
# a class method to create a Person object by birth year.
@classmethod
dataset, val_set = torch.utils.data.random_split(dataset,[int(len(dataset) * 0.85),
len(dataset) - int(len(dataset) * 0.85)])
config.manual_seed = 33
print("Random Seed: ", config.manual_seed)
random.seed(config.manual_seed)
torch.manual_seed(config.manual_seed)
if torch.cuda.is_available():
torch.cuda.manual_seed_all(config.manual_seed)
@umitkacar
umitkacar / Install_OpenCV4_CUDA11_CUDNN8.md
Created November 14, 2022 09:25 — forked from raulqf/Install_OpenCV4_CUDA11_CUDNN8.md
How to install OpenCV 4.5 with CUDA 11.2 in Ubuntu 20.04

How to install OpenCV 4.5.2 with CUDA 11.2 and CUDNN 8.2 in Ubuntu 20.04

First of all install update and upgrade your system:

    $ sudo apt update
    $ sudo apt upgrade

Then, install required libraries:

#!/bin/bash
import subprocess
subprocess.run(["./zip.sh"])
subprocess.run(["zip", "-r", "test.zip", "test/"], capture_output=True)
# https://docs.python.org/3/library/subprocess.html
@umitkacar
umitkacar / cuda_11.3_installation_on_Ubuntu_20.04
Last active September 18, 2023 18:27 — forked from Mahedi-61/cuda_11.8_installation_on_Ubuntu_22.04
Instructions for CUDA v11.3 and cuDNN 8.2 installation on Ubuntu 20.04 for PyTorch 1.11
#!/bin/bash
## https://deeplearningcrashcourse.org/setup_ubuntu/
### steps ####
# verify the system has a cuda-capable gpu
# download and install the nvidia cuda toolkit and cudnn
# setup environmental variables
# verify the installation
###