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
# Cutting .wav file from start to end | |
# ffmpeg -i <in_file> -ss <start_sec> -to <end_sec> -c copy <out_file> | |
# ffmpeg -i 1.mp3 -ss 0 -to 60 -c copy 2.mp3 (example of use) | |
# Generating mono .wav file | |
# ffmpeg -i <in_file> -acodec pcm_s16le -ac 1 -ar 16000 <out_file> | |
# ffmpeg -i 2.mp3 -acodec pcm_s16le -ac 1 -ar 16000 2.wav | |
# Combine both | |
# ffmpeg -i 1.mp3 -ss 0 -to 60 -c -acodec pcm_s16le -ac 1 -ar 16000 copy out.wav |
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
""" | |
Create train, valid, test iterators for CIFAR-10 [1]. | |
Easily extended to MNIST, CIFAR-100 and Imagenet. | |
[1]: https://discuss.pytorch.org/t/feedback-on-pytorch-for-kaggle-competitions/2252/4 | |
""" | |
import torch | |
import numpy as np | |
from utils import plot_images |
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 time | |
import torch | |
class AverageMeter: | |
def __init__(self): | |
self.reset() | |
def reset(self): | |
self.val = 0 | |
self.avg = 0 |
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 time | |
import torch | |
class Tag: | |
def __init__(self, topk=(1,), verbose=True): | |
self.__topk = topk | |
self.__verbose = verbose | |
def __call__(self, data_loader): | |
self.__time_start = time.time() |
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
# Example: | |
# $ python argparse_dict_argument.py --env a=b --env aa=bb | |
# Namespace(env={'a': 'b', 'aa': 'bb'}) | |
import argparse | |
parser = argparse.ArgumentParser() | |
parser.add_argument('--env', action = type('', (argparse.Action, ), dict(__call__ = lambda a, p, n, v, o: getattr(n, a.dest).update(dict([v.split('=')])))), default = {}) # anonymously subclassing argparse.Action | |
print parser.parse_args() |
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 time | |
import torch | |
import torch.nn as nn | |
import torch.nn.functional as F | |
import torch.optim as optim | |
from torch.utils.data import DataLoader, random_split | |
from torchvision import datasets, transforms | |
from activation import load_actF |
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 sqlalchemy import create_engine | |
db = create_engine('postgresql://user:password@localhost:port/database') | |
for i in range(1,2000): | |
conn = db.connect() | |
#some simple data operations | |
conn.close() | |
db.dispose() |
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 pandas as pd | |
from sqlalchemy import create_engine | |
engine = create_engine('postgresql://id:password@localhost:port/database') | |
df.to_sql('table_name', engine) | |
pd.read_sql("select * from users limit 1", engine) |
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 pandas as pd | |
import pyodbc | |
from sqlalchemy import create_engine | |
engine = create_engine("mssql+pyodbc://DESKTOP-R5QA5N1/test?driver=SQL+Server+Native+Client+11.0") | |
df = pd.DataFrame([1]) | |
df.to_sql('test', con=engine) |
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 PySide2.QtWidgets import QApplication, QMainWindow, QMdiArea, QAction, QMdiSubWindow, QTextEdit | |
import sys | |
class MDIWindow(QMainWindow): | |
count = 0 | |
def __init__(self): | |
super().__init__() |