First of all install update and upgrade your system:
$ sudo apt update
$ sudo apt upgrade
Then, install required libraries:
from torchvision import transforms | |
transform = transforms.Compose([ | |
transforms.ToTensor(), # Bu metot PIL.Image veya numpy.ndarray (H x W x C) [0, 255] verilerini | |
# torch.FloatTensor (C x H x W) [0.0, 1.0] formatına dönüştürür. | |
]) | |
class CustomDataset(torch.utils.data.Dataset): | |
def __init__(self, image_paths, transform=None): | |
self.image_paths = image_paths |
tmux | |
tmux ls | |
tmux attach -d -t 0 |
from redlines import Redlines | |
diff = Redlines(text,response) | |
display(Markdown(diff.output_markdown)) |
#!/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 | |
### |
#!/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 |
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) |
# 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 |
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] |
if not os.path.exists("output"): | |
os.makedirs("output") |