code stringlengths 17 6.64M |
|---|
def set_host_only(host_only: bool):
'ホスト(CPU)のみの指定\n\n True を設定するとデバイス(GPU)を未使用としてホスト(CPU)のみを利用\n\n Args:\n host_only (bool) : ホストのみの場合 True を指定\n '
core.Manager.set_host_only(host_only)
|
def get_cuda_driver_version():
'CUDAドライババージョンの取得\n\n Returns:\n driver_version (int) : CUDAドライババージョン\n '
return core.get_cuda_driver_version()
|
def get_cuda_driver_version_string():
'CUDAドライババージョン文字列の取得\n\n Returns:\n driver_version (str) : CUDAドライババージョン文字列\n '
driver_version = get_cuda_driver_version()
major = (driver_version // 1000)
minor = ((driver_version % 1000) // 10)
return '{}.{}'.format(major, minor)
|
def get_device_count():
'利用可能なデバイス(GPU)の個数を確認\n\n Returns:\n device_count (int) : 利用可能なデバイス(GPU)の個数を返す\n '
return core.get_device_count()
|
def set_device(device_id):
'利用するデバイス(GPU)を切り替え\n\n Args:\n device_id (int) : 利用するデバイス番号を指定\n '
core.set_device(device_id)
|
def get_device_properties_string(device_id):
'現在のデバイス(GPU)の情報を入れた文字列を取得\n\n Args:\n device_id (int) : 情報を取得するデバイス番号を指定\n\n Returns:\n device_properties_string (str) : 現在のデバイス(GPU)の情報を入れた文字列を返す\n '
return core.get_device_properties_string(device_id)
|
def get_device_properties(device_id):
return core.get_device_properties(device_id)
|
def get_device_name(device_id):
return core.get_device_name(device_id)
|
def get_device_allocated_memory_size():
return core.get_device_allocated_memory_size()
|
def garbage_collect_device_memory():
return core.garbage_collect_device_memory()
|
class Tensor(bb.Object):
'Tensor class\n\n 多次元データ構造。\n\n Args:\n shape (list[int]): Shape of created array\n dtype (int): Data type\n host_only (bool): flag of host only\n '
def __init__(self, shape: List[int]=None, *, dtype=bb.DType.FP32, host_only=False, core_tensor=None)... |
class Variables():
'Variables class\n\n 学習の為の Optimizer と実際の学習ターゲットの変数の橋渡しに利用されるクラス。\n 内部的には各モデル内の重みや勾配を保有する Tensor をまとめて保持している。\n '
def __init__(self):
self.variables = core.Variables()
@staticmethod
def from_core(variables):
new_variables = Variables()
new_va... |
def make_verilog_lut_layers(module_name: str, net, device=''):
' make verilog source of LUT layers\n 変換できないモデルは影響ない層とみなして無視するので注意\n \n Args:\n module_name (str): モジュール名\n net (Model): 変換するネット\n \n Returns:\n Verilog source code (str)\n '
l... |
def dump_verilog_lut_layers(f, module_name: str, net, device=''):
' dump verilog source of LUT layers\n 変換できないモデルは影響ない層とみなして無視するので注意\n \n Args:\n f (StreamIO) : 出力先ストリーム\n module_name (str): モジュール名\n net (Model): 変換するネット\n '
f.write(make_verilog_lut_layers(... |
def export_verilog_lut_layers(file_name: str, module_name: str, net):
with open(file_name, 'w') as f:
dump_verilog_lut_layers(f, module_name, net)
|
def make_verilog_lut_cnv_layers(module_name: str, net, device=''):
layers = bb.get_model_list_for_rtl(net)
core_layers = []
for layer in layers:
core_layers.append(layer.get_core())
return core.make_verilog_lut_cnv_layers(module_name, core_layers, device)
|
def dump_verilog_lut_cnv_layers(f, module_name: str, net, device=''):
' dump verilog source of Convolutional LUT layers\n \n 畳み込み層を含むネットを AXI4 Stream Video 形式のVerilogソースコードして\n 出力する。\n 縮小を伴う MaxPooling 層は最後に1個だけ挿入を許される\n\n Args:\n f (StreamIO) : 出力先ストリーム\n ... |
def export_verilog_lut_cnv_layers(file_name: str, module_name: str, net, device=''):
with open(file_name, 'w') as f:
dump_verilog_lut_cnv_layers(f, module_name, net, device)
|
def __dump_bin_digit(f, v):
if v:
f.write('1')
else:
f.write('0')
|
def __dump_bin_int(f, v, digits):
for i in range(digits):
__dump_bin_digit(f, ((v >> ((digits - 1) - i)) & 1))
|
def __dump_bin_img(f, img):
img = np.array(img).flatten()[::(- 1)]
for v in img:
__dump_bin_digit(f, (v > 0.5))
|
def dump_verilog_readmemb_image_classification(f, loader, *, class_digits=8):
'verilog用データダンプ\n verilog の $readmemb() での読み込み用データ作成\n\n クラスID + 画像データの形式で出力する\n\n Args:\n f (StreamIO): 出力先\n loader (Loader): モジュール名\n class_digits (int): クラス分類のbit数\n '
for (images, labels) in loa... |
def make_image_tile(rows, cols, img_gen):
'画像をタイル状に並べて大きな画像にする\n\n 学習用の c, h, w 順の画像データをタイル状に結合する\n\n Args:\n rows (int)): 縦の結合枚数\n cols (int)): 横の結合枚数\n gen (ndarray): 画像を返すジェネレータ\n\n Returns:\n img (ndarray) : 作成した画像\n '
def make_image_tile_h(cols, img_gen):
... |
def write_ppm(fname, img):
'ppmファイルの出力\n\n 学習用の c, h, w 順の画像データを ppm形式で保存する\n\n Args:\n fname (str): 出力ファイル名\n img (ndarray): モジュール名\n '
if ((img.ndim == 3) and (img.shape[0] == 1)):
img = np.tile(img, (3, 1, 1))
elif (img.ndim == 2):
img = np.stack((img, img, im... |
def find_in_path(name, path):
for dir in path.split(os.pathsep):
binpath = pjoin(dir, name)
if os.path.exists(binpath):
return os.path.abspath(binpath)
return None
|
def search_cuda():
if (sys.platform.startswith('win32') and ('CUDA_PATH' in os.environ)):
cuda_home = os.environ['CUDA_PATH']
cuda_bin = pjoin(cuda_home, 'bin')
cuda_include = pjoin(cuda_home, 'include')
cuda_lib = pjoin(cuda_home, 'lib', 'x64')
cuda_nvcc = pjoin(cuda_bin, ... |
class get_pybind_include(object):
'Helper class to determine the pybind11 include path\n The purpose of this class is to postpone importing pybind11\n until it is actually installed, so that the ``get_include()``\n method can be invoked. '
def __init__(self, user=False):
self.user = user
... |
def hook_compiler(self):
self.src_extensions.append('.cu')
super_compile_ = self._compile
super_compile = self.compile
super_link = self.link
def _compile(obj, src, ext, cc_args, extra_postargs, pp_opts):
if VERBOSE:
print('---------------------')
print('[_compile]... |
class BuildExt(build_ext):
'A custom build extension for adding compiler-specific options.'
cc_args = {'unix': [], 'msvc': []}
cu_args = {'unix': [], 'msvc': []}
ar_args = {'unix': [], 'msvc': []}
if (CUDA is None):
cc_args['unix'] += ['-mavx2', '-mfma', '-fopenmp', '-std=c++14']
a... |
def make_conv_layer(output_shape, filter_size, bin_dtype):
return bb.Convolution2d(bb.Sequential([bb.DenseAffine(output_shape), bb.BatchNormalization(), bb.ReLU(bin_dtype=bin_dtype)]), filter_size=filter_size, fw_dtype=bin_dtype)
|
def learning(net_name, frame_modulation_size, depth_modulation_size=1, epochs=8, bin_mode=True):
save_path = os.path.join(data_path, net_name)
bin_dtype = (bb.DType.BIT if bin_mode else bb.DType.FP32)
net = bb.Sequential([make_conv_layer([32], filter_size=(3, 3), bin_dtype=bin_dtype), make_conv_layer([64]... |
class DifferentiableLutBlock(bb.Sequential):
def __init__(self, output_shape, depth, name=None, batch_norm=True, binarize=True, average=True, bin_dtype=bb.DType.FP32):
self.layers = []
for i in range(depth):
if (name is None):
layer_name = None
else:
... |
class DifferentiableLutConvolution2d(bb.Convolution2d):
def __init__(self, output_ch, depth, filter_size=(3, 3), padding='valid', batch_norm=True, binarize=True, name=None, fw_dtype=bb.DType.FP32):
super(DifferentiableLutConvolution2d, self).__init__(DifferentiableLutBlock([output_ch, 1, 1], depth, batch... |
def make_conv_layer(output_ch, hidden_ch, padding='valid', bin_dtype=bb.DType.BIT):
return bb.Sequential([bb.Convolution2d(bb.Sequential([bb.DifferentiableLut([(hidden_ch * 6), 1, 1], bin_dtype=bin_dtype), bb.DifferentiableLut([hidden_ch, 1, 1], connection='serial', bin_dtype=bin_dtype)]), filter_size=(1, 1), fw_... |
def main():
data_path = './data/'
net_name = 'MnistDifferentiableLutSimple'
data_path = os.path.join('./data/', net_name)
rtl_sim_path = '../../verilog/mnist/tb_mnist_lut_simple'
rtl_module_name = 'MnistLutSimple'
output_velilog_file = os.path.join(data_path, (net_name + '.v'))
sim_velilog... |
def make_conv_layer(output_shape, filter_size, bin_dtype):
return bb.Convolution2d(bb.Sequential([bb.DenseAffine(output_shape), bb.BatchNormalization(), bb.ReLU(bin_dtype=bin_dtype)]), filter_size=filter_size, fw_dtype=bin_dtype)
|
def learning(net_name, frame_modulation_size, depth_modulation_size=1, epochs=8, bin_mode=True):
save_path = os.path.join(data_path, net_name)
bin_dtype = (bb.DType.BIT if bin_mode else bb.DType.FP32)
net = bb.Sequential([make_conv_layer([32], filter_size=(3, 3), bin_dtype=bin_dtype), make_conv_layer([64]... |
class DifferentiableLutBlock(bb.Sequential):
def __init__(self, output_shape, depth, name=None, batch_norm=True, binarize=True, average=True, bin_dtype=bb.DType.FP32):
self.layers = []
for i in range(depth):
if (name is None):
layer_name = None
else:
... |
class DifferentiableLutConvolution2d(bb.Convolution2d):
def __init__(self, output_ch, depth, filter_size=(3, 3), padding='valid', batch_norm=True, binarize=True, name=None, fw_dtype=bb.DType.FP32):
super(DifferentiableLutConvolution2d, self).__init__(DifferentiableLutBlock([output_ch, 1, 1], depth, batch... |
def make_conv_layer(hidden_ch, output_ch, padding='same', bin_dtype=bb.DType.BIT):
return bb.Sequential([bb.Convolution2d(bb.Sequential([bb.DifferentiableLut([(hidden_ch * 6), 1, 1], bin_dtype=bin_dtype), bb.DifferentiableLut([hidden_ch, 1, 1], connection='serial', bin_dtype=bin_dtype)]), filter_size=(1, 1), fw_d... |
def make_lut_func_name(name, node):
return ('%s_%d' % (name, node))
|
def dump_hls_lut_node5(f, name, lut, node):
n = lut.get_node_connection_size(node)
s = lut.get_lut_table_size(node)
tbl = 0
for i in range(s):
if lut.get_lut_table(node, i):
tbl += (1 << i)
f.write(('Q(%s,0x%016xLL)\n' % (make_lut_func_name(name, node), tbl)))
|
def dump_hls_lut_node4(f, name, lut, node):
f.write(('\nap_uint<1> %s(\n' % make_lut_func_name(name, node)))
n = lut.get_node_connection_size(node)
s = lut.get_lut_table_size(node)
tbl = 0
for i in range(s):
if lut.get_lut_table(node, i):
tbl += (1 << i)
for i in range(n):
... |
def dump_hls_lut_node3(f, name, lut, node):
f.write(('\ninline ap_uint<1> %s(\n' % make_lut_func_name(name, node)))
n = lut.get_node_connection_size(node)
s = lut.get_lut_table_size(node)
tbl = 0
for i in range(s):
if lut.get_lut_table(node, i):
tbl += (1 << i)
for i in ran... |
def dump_hls_lut_node2(f, name, lut, node):
f.write(('\ninline ap_uint<1> %s(\n' % make_lut_func_name(name, node)))
n = lut.get_node_connection_size(node)
s = lut.get_lut_table_size(node)
for i in range(n):
f.write((' ap_uint<1> in_data%d' % i))
if (i < (n - 1)):
f.w... |
def dump_hls_lut_node1(f, name, lut, node):
f.write(('\ninline ap_uint<1> %s(\n' % make_lut_func_name(name, node)))
n = lut.get_node_connection_size(node)
s = lut.get_lut_table_size(node)
tbl = 0
for i in range(s):
if lut.get_lut_table(node, i):
tbl += (1 << i)
for i in ran... |
def dump_hls_lut(f, name, lut):
ins = lut.get_input_node_size()
outs = lut.get_output_node_size()
for node in range(outs):
dump_hls_lut_node5(f, name, lut, node)
f.write('\n')
f.write(('inline ap_uint<%d> %s(ap_uint<%d> i)\n' % (outs, name, ins)))
f.write('{\n')
f.write(('ap_uint<%... |
def make_lut_func_name(name, node):
return ('%s_%d' % (name, node))
|
def dump_hls_lut_node5(f, name, lut, node):
n = lut.get_node_connection_size(node)
s = lut.get_lut_table_size(node)
tbl = 0
for i in range(s):
if lut.get_lut_table(node, i):
tbl += (1 << i)
f.write(('Q(%s,0x%016xLL)\n' % (make_lut_func_name(name, node), tbl)))
|
def dump_hls_lut_node4(f, name, lut, node):
f.write(('\nap_uint<1> %s(\n' % make_lut_func_name(name, node)))
n = lut.get_node_connection_size(node)
s = lut.get_lut_table_size(node)
tbl = 0
for i in range(s):
if lut.get_lut_table(node, i):
tbl += (1 << i)
for i in range(n):
... |
def dump_hls_lut_node3(f, name, lut, node):
f.write(('\ninline ap_uint<1> %s(\n' % make_lut_func_name(name, node)))
n = lut.get_node_connection_size(node)
s = lut.get_lut_table_size(node)
tbl = 0
for i in range(s):
if lut.get_lut_table(node, i):
tbl += (1 << i)
for i in ran... |
def dump_hls_lut_node2(f, name, lut, node):
f.write(('\ninline ap_uint<1> %s(\n' % make_lut_func_name(name, node)))
n = lut.get_node_connection_size(node)
s = lut.get_lut_table_size(node)
for i in range(n):
f.write((' ap_uint<1> in_data%d' % i))
if (i < (n - 1)):
f.w... |
def dump_hls_lut_node1(f, name, lut, node):
f.write(('\ninline ap_uint<1> %s(\n' % make_lut_func_name(name, node)))
n = lut.get_node_connection_size(node)
s = lut.get_lut_table_size(node)
tbl = 0
for i in range(s):
if lut.get_lut_table(node, i):
tbl += (1 << i)
for i in ran... |
def dump_hls_lut(f, name, lut):
ins = lut.get_input_node_size()
outs = lut.get_output_node_size()
for node in range(outs):
dump_hls_lut_node5(f, name, lut, node)
f.write('\n')
f.write(('inline ap_uint<%d> %s(ap_uint<%d> i)\n' % (outs, name, ins)))
f.write('{\n')
f.write(('ap_uint<%... |
def make_lut_func_name(name, node):
return ('%s_lut_%d' % (name, node))
|
def dump_hls_lut_node2(f, name, lut, node):
f.write(('\ninline ap_uint<1> %s(\n' % make_lut_func_name(name, node)))
n = lut.get_node_connection_size(node)
s = lut.get_lut_table_size(node)
for i in range(n):
f.write((' ap_uint<1> in_data%d' % i))
if (i < (n - 1)):
f.w... |
def dump_hls_lut_node(f, name, lut, node):
f.write(('\ninline ap_uint<1> %s(\n' % make_lut_func_name(name, node)))
n = lut.get_node_connection_size(node)
s = lut.get_lut_table_size(node)
tbl = 0
for i in range(s):
if lut.get_lut_table(node, i):
tbl += (1 << i)
for i in rang... |
def dump_hls_lut(f, name, lut):
ins = lut.get_input_node_size()
outs = lut.get_output_node_size()
for node in range(outs):
dump_hls_lut_node2(f, name, lut, node)
f.write('\n')
f.write(('inline ap_uint<%d> %s(ap_uint<%d> in_data)\n' % (outs, name, ins)))
f.write('{\n')
f.write((' ... |
def plot_image(img):
img = img.reshape(3, 32, 32).transpose(1, 2, 0)
plt.imshow(img)
|
def create_conv_layer(shape, w, h, batch_norm=False, act=True, padding='valid'):
sub_net = bb.Sequential.create()
sub_net.add(bb.DenseAffine.create(shape))
if batch_norm:
sub_net.add(bb.BatchNormalization.create())
if act:
sub_net.add(bb.ReLU.create())
return bb.LoweringConvolution... |
def plot_image(img):
img = img.reshape(3, 32, 32).transpose(1, 2, 0)
plt.imshow(img)
|
def create_conv_layer(sub_layers, w, h, padding='valid'):
sub_net = bb.Sequential.create()
for layer in sub_layers:
sub_net.add(layer)
return bb.LoweringConvolutionBit.create(sub_net, w, h, 1, 1, padding=padding)
|
def loadTags(filename):
with open(filename) as f:
reader = csv.reader(f)
data = list(reader)
tagName = [r[0] for r in data]
return (tagName, dict(zip(tagName, range(len(tagName)))))
|
def getTagScore(scores, tags, tag2IDs):
scores = np.exp(scores)
scores /= scores.sum()
tagScore = []
for r in tags:
tagScore.append((r, scores[tag2IDs[r]]))
return tagScore
|
def showAttMap(img, attMaps, tagName, overlap=True, blur=False):
pylab.rcParams['figure.figsize'] = (12.0, 12.0)
(f, ax) = plt.subplots(((len(tagName) / 2) + 1), 2)
if (len(ax.shape) == 1):
ax[0].imshow(img)
else:
ax[(0, 0)].imshow(img)
for i in range(len(tagName)):
attMap ... |
def Normalize(a):
return ((a - a.min()) / (a.max() - a.min()))
|
def doGradCAM(net, img, tagID, top=topLayerName, bottom=outputLayerName):
caffe.set_mode_gpu()
out = net.forward(end=top)
net.blobs[top].diff[0][...] = 0
net.blobs[top].diff[0][tagID] = 1
fprop_maps = net.blobs[bottom].data[0]
out = net.backward(start=top, end=bottom)
map_weights = net.blo... |
def repro_fig_3(gpu=None, interp='nearest'):
net = caffe.Net('/home/ruthfong/packages/caffe/models/vgg16/VGG_ILSVRC_16_layers_deploy_force_backward.prototxt', '/home/ruthfong/packages/caffe/models/vgg16/VGG_ILSVRC_16_layers.caffemodel', caffe.TEST)
transformer = get_ILSVRC_net_transformer(net)
topName = '... |
def repro_fig_4(gpu=None, interp='bicubic'):
net = caffe.Net('/home/ruthfong/packages/caffe/models/bvlc_googlenet/deploy_force_backward.prototxt', '/home/ruthfong/packages/caffe/models/bvlc_googlenet/bvlc_googlenet.caffemodel', caffe.TEST)
topName = 'loss3/classifier'
bottomName = 'pool2/3x3_s2'
zebra... |
def main():
gpu = 0
net_type = 'googlenet'
caffe.set_device(gpu)
caffe.set_mode_gpu()
net = get_net(net_type)
labels_desc = np.loadtxt('/home/ruthfong/packages/caffe/data/ilsvrc12/synset_words.txt', str, delimiter='\t')
synsets = np.loadtxt('/home/ruthfong/packages/caffe/data/ilsvrc12/syns... |
def load_valid_paths():
with open('./valid_paths.txt', 'r') as fp:
paths = [line.strip() for line in fp if (line.strip() != '')]
return paths
|
def get_third_party():
txt_files = list(Path('./requirements').rglob('*.txt'))
package_list = []
for file in txt_files:
with open(file, 'r') as fp:
for line in fp:
line = line.strip()
if (line == ''):
continue
package_... |
def run_command(command: str):
try:
check_output(command.split(' '))
except CalledProcessError as e:
print(e.output.decode('utf-8'))
raise
|
def main():
parser = argparse.ArgumentParser()
parser.add_argument('files', type=str, nargs='*', default=[], help='If no file is given, use the files under ./valid_paths.txt')
parser.add_argument('--check', action='store_true', help='Only checks the files')
args = parser.parse_args()
if (len(args.... |
def linkcode_resolve(domain, info):
def find_source():
obj = sys.modules[info['module']]
for part in info['fullname'].split('.'):
obj = getattr(obj, part)
if isinstance(obj, property):
return None
file_parts = Path(inspect.getsourcefile(obj)).parts
... |
class LowResourceLinearSuperbASR(SuperbASR):
def prepare_data(self, prepare_data: dict, target_dir: str, cache_dir: str, get_path_only=False):
(train_path, valid_path, test_paths) = super().prepare_data(prepare_data, target_dir, cache_dir, get_path_only)
df = pd.read_csv(train_path)
df = ... |
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument('problem', help='The problem module. E.g. `s3prl.problem.ssl.tera.Tera`')
parser.add_argument('dataset_root', help='The dataset root for pretrain.')
parser.add_argument('save_to', help='The directory to save checkpoint')
pars... |
def main():
logging.basicConfig(level=logging.INFO)
(problem, config) = parse_args()
save_to = Path(config.save_to)
save_to.mkdir(exist_ok=True, parents=True)
body = problem.Body(**config.Body)
head = problem.Head(**config.Head)
loss = problem.Loss(**config.Loss)
stats = Container()
... |
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument('upstream', help='The upstream name. E.g. wav2vec2')
parser.add_argument('problem', help='The problem module. E.g. s3prl.problem.SuperbSID')
parser.add_argument('dataset_root', help='The dataset root of your problem.')
parser... |
def main():
logging.basicConfig(level=logging.INFO)
(problem, config) = parse_args()
save_to = Path(config.save_to)
save_to.mkdir(exist_ok=True, parents=True)
upstream = S3PRLUpstream(config.upstream, config.feature_selection)
stats = Container(upstream_rate=upstream.downsample_rate)
logge... |
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument('load_from', help='The directory containing all the checkpoints')
args = parser.parse_args()
return args
|
def main():
args = parse_args()
load_from = Path(args.load_from)
task: Task = Object.load_checkpoint((load_from / 'task.ckpt')).to(device)
task.eval()
test_dataset: Dataset = Object.load_checkpoint((load_from / 'test_dataset.ckpt'))
test_dataloader = test_dataset.to_dataloader(batch_size=1, nu... |
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument('librispeech', help='The root directory of LibriSpeech')
parser.add_argument('save_to', help='The directory to save checkpoint')
parser.add_argument('--total_steps', type=int, default=200000)
parser.add_argument('--log_step',... |
def main():
logging.basicConfig()
logger.setLevel(logging.INFO)
args = parse_args()
librispeech = Path(args.librispeech)
assert librispeech.is_dir()
save_to = Path(args.save_to)
save_to.mkdir(exist_ok=True, parents=True)
logger.info('Preparing preprocessor')
preprocessor = problem.... |
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument('librispeech', help='The root directory of LibriSpeech')
parser.add_argument('save_to', help='The directory to save checkpoint')
parser.add_argument('--total_steps', type=int, default=200000)
parser.add_argument('--log_step',... |
def main():
logging.basicConfig(level=logging.INFO)
args = parse_args()
librispeech = Path(args.librispeech)
save_to = Path(args.save_to)
save_to.mkdir(exist_ok=True, parents=True)
logger.info('Preparing preprocessor')
preprocessor = problem.Preprocessor(librispeech)
logger.info('Prepa... |
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument('load_from', help='The directory containing all the checkpoints')
args = parser.parse_args()
return args
|
def main():
args = parse_args()
load_from = Path(args.load_from)
task: Task = Object.load_checkpoint((load_from / 'task.ckpt')).to(device)
task.eval()
test_dataset: Dataset = Object.load_checkpoint((load_from / 'test_dataset.ckpt'))
test_dataloader = test_dataset.to_dataloader(batch_size=1, nu... |
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument('voxceleb1', help='The root directory of VoxCeleb1')
parser.add_argument('save_to', help='The directory to save checkpoint')
parser.add_argument('--total_steps', type=int, default=200000)
parser.add_argument('--log_step', typ... |
def main():
logging.basicConfig()
logger.setLevel(logging.INFO)
args = parse_args()
voxceleb1 = Path(args.voxceleb1)
assert voxceleb1.is_dir()
save_to = Path(args.save_to)
save_to.mkdir(exist_ok=True, parents=True)
logger.info('Preparing preprocessor')
preprocessor = problem.Prepro... |
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument('voxceleb1', help='The root directory of VoxCeleb1')
parser.add_argument('save_to', help='The directory to save checkpoint')
parser.add_argument('--total_steps', type=int, default=200000)
parser.add_argument('--log_step', typ... |
def main():
logging.basicConfig(level=logging.INFO)
args = parse_args()
voxceleb1 = Path(args.voxceleb1)
save_to = Path(args.save_to)
save_to.mkdir(exist_ok=True, parents=True)
logger.info('Preparing preprocessor')
preprocessor = problem.Preprocessor(voxceleb1)
logger.info('Preparing t... |
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument('--load_from', type=str, default='result/sv', help='The directory containing all the checkpoints')
args = parser.parse_args()
return args
|
def main():
args = parse_args()
load_from = Path(args.load_from)
task: Task = Object.load_checkpoint((load_from / 'task.ckpt')).to(device)
task.eval()
test_dataset: Dataset = Object.load_checkpoint((load_from / 'test_dataset.ckpt'))
test_dataloader = DataLoader(test_dataset, batch_size=1, num_... |
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument('--voxceleb1', type=str, default='/work/jason410/PublicData/Voxceleb1', help='The root directory of VoxCeleb1')
parser.add_argument('--save_to', type=str, default='result/sv', help='The directory to save checkpoint')
parser.add_a... |
def main():
logging.basicConfig()
logger.setLevel(logging.INFO)
args = parse_args()
voxceleb1 = Path(args.voxceleb1)
assert voxceleb1.is_dir()
save_to = Path(args.save_to)
save_to.mkdir(exist_ok=True, parents=True)
logger.info('Preparing preprocessor')
preprocessor = problem.Prepro... |
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument('--voxceleb1', type=str, default='/work/jason410/PublicData/Voxceleb1', help='The root directory of VoxCeleb1')
parser.add_argument('--save_to', type=str, default='lightning_result/sv', help='The directory to save checkpoint')
pa... |
def main():
logging.basicConfig()
logger.setLevel(logging.INFO)
args = parse_args()
voxceleb1 = Path(args.voxceleb1)
assert voxceleb1.is_dir()
save_to = Path(args.save_to)
save_to.mkdir(exist_ok=True, parents=True)
logger.info('Preparing preprocessor')
preprocessor = problem.Prepro... |
def default_collate_fn(samples, padding_value: int=0):
'\n Each item in **DynamicItemDataset** is a dict\n This function pad (or transform into numpy list) a batch of dict\n\n Args:\n samples (List[dict]): Suppose each Container is in\n\n .. code-block:: yaml\n\n wav: a s... |
class Corpus():
@property
@abc.abstractmethod
def all_data(self) -> dict:
raise NotImplementedError
@property
@abc.abstractmethod
def data_split_ids(self):
raise NotImplementedError
@property
def data_split(self):
(train_ids, valid_ids, test_ids) = self.data_... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.