pip3 install torch==1.9.1+cu111 -f https://nelsonliu.me/files/pytorch/whl/torch_stable.html
pip3 install torchvision==0.10.1+cu111 torchaudio==0.9.1 -f https://download.pytorch.org/whl/torch_stable.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if not os.path.exists("output"): | |
os.makedirs("output") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 | |
### |
OlderNewer