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
# Progress Bar 1 | |
import progressbar as pb | |
widg = ['Processed: ', pb.Counter(), ' lines (', pb.Timer(), ')'] | |
pbar = pb.ProgressBar(widgets=widg) | |
for i in pbar(content): | |
some code | |
# Progress Bar 2 |
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 chardet | |
import pandas as pd | |
def find_encoding(fname): | |
r_file = open(fname, 'rb').read() | |
result = chardet.detect(r_file) | |
charenc = result['encoding'] | |
return charenc |
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
#!/usr/bin/env python3 | |
# Importing all needed modules | |
import multiprocessing | |
import random | |
import time | |
import timeit | |
print("Starting Multiprocessing...") |
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 torch | |
from torch import nn | |
cl_1 = nn.Conv2d(1, 64, 3) | |
mp_1 = nn.MaxPool2d(2) | |
cl_2 = nn.Conv2d(64, 128, 3) | |
mp_2 = nn.MaxPool2d(2) | |
cl_3 = nn.Conv2d(128, 512, 3) |
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
# Convolutional neural network (two convolutional layers) | |
class ConvNet(nn.Module): | |
def __init__(self): | |
super(ConvNet, self).__init__() | |
self.network2D = nn.Sequential( | |
nn.Conv2d(1, 32, kernel_size=5, stride=1, padding=2), | |
nn.ReLU(), | |
nn.MaxPool2d(kernel_size=2, stride=2), | |
nn.Conv2d(32, 64, kernel_size=5, stride=1, padding=2), | |
nn.ReLU(), |
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
def humanize_bytes(bytes, precision=1): | |
"""Return a humanized string representation of a number of bytes. | |
Assumes `from __future__ import division`. | |
>>> humanize_bytes(1) | |
'1 byte' | |
>>> humanize_bytes(1024) | |
'1.0 kB' | |
>>> humanize_bytes(1024*123) | |
'123.0 kB' | |
>>> humanize_bytes(1024*12342) |
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
from tqdm import tqdm | |
l = ['this', 'is', 'a', 'list'] | |
for word in tqdm(l): | |
do_something(word) |