python
文章平均质量分 59
masonwang_513
Algorithm engineer in computer vision
展开
-
制作Pascal Voc 格式标柱文件
# -*- coding: utf-8 -*-import osimport cv2import shutilfrom xml.etree import ElementTreefrom xml.etree.ElementTree import Element, SubElementdef pretty_xml(element, indent, newline, level=0): """ 通过加入缩进、换行,美化xml :param element: Elment类.原创 2021-07-21 10:07:44 · 148 阅读 · 0 评论 -
python 派生类方法重写必须要有相同的函数签名吗
QuestionPython Method overriding, does signature matter?Lets say I haveclass Super(): def method1(): passclass Sub(Super): def method1(param1, param2, param3): stuffIs this correct? Will calls to method1 always go to the sub cl...转载 2021-04-28 11:44:19 · 1215 阅读 · 0 评论 -
pytorch DistributedDataParallel
1. 为什么每个epoch都要调用distributed_sampler.set_epoch(epoch) 函数一次?torch.utils.data.distributed.DistributedSampler: 在多机多卡情况下分布式训练数据的读取也是一个问题,不同的卡读取到的数据应该是不同的。dataparallel的做法是直接将batch切分到不同的卡,这种方法对于多机来说不可取,因为多机之间直接进行数据传输会严重影响效率。于是有了利用distributed_sampler确保datalo...原创 2021-02-23 10:01:41 · 363 阅读 · 0 评论 -
python 派生类方法可以改变函数签名
派生类方法是可以改变父类方法的函数签名的,但为了避免出错,父类方法要满足LSP.class Super(): def method1(*args): passclass Sub(Super): def method1(param1, param2, param3): stuffIn Python, methods are just key-value pairs in the dictionary attached to the class. When you a原创 2021-01-23 17:33:07 · 269 阅读 · 0 评论 -
python 修饰器
修饰器就是一个普通的python函数,接受一个函数作为其唯一的参数, 并返回一个新函数(一般是传入函数的封装)。下面的my_decorator就是一个简单的修饰函数:def my_decorator(func): def wrapper(): print("Something is happening before the function is called.") func() print("Something is happening a原创 2020-12-22 10:12:43 · 178 阅读 · 1 评论 -
Python打包分发工具setuptools简介与扩展
Python打包分发工具setuptools简介作为Python标准的打包及分发工具,setuptools可以说相当地简单易用。它会随着Python一起安装在你的机器上。你只需写一个简短的setup.py安装文件,就可以将你的Python应用打包。本文就会介绍下如何编写安装文件及如何打包分发。首先,如果你需要另外安装setuptools,你可以使用下面的命令:$ wget http://peak.telecommunity.com/dist/ez_setup.py$ sudo pyth.原创 2020-12-16 13:36:34 · 303 阅读 · 0 评论 -
h5py vs npy/npz
Data engineering for computer visionLately, I've been thinking hard about the best way to organize my data before feeding it to a machine learning classifier or regressor. I have a few guiding princ...转载 2020-04-30 15:17:08 · 1217 阅读 · 0 评论 -
python multiprocessing 中imap和map的不同
本篇文章讲python的multiprocessing中imap、map、imap_unordered和map_async方法之间的区别。参考链接主要有以下两个区别:它们使用你传递给它们的可迭代的对象的方式。 它们返回结果的方式。map通过将改可迭代的对象转换为列表(假设它不是列表), 将其分解为块,并将这些块发送到池中的工作进程中。 将该对象分解为块比一次直接执行一个对象要更...转载 2020-04-30 14:13:20 · 6485 阅读 · 0 评论 -
map vs imap in multiprocessing.Pool
There are two key differences betweenimap/imap_unorderedandmap/map_async:The way they consume the iterable you pass to them. The way they return the result back to you.mapconsumes your iterabl...转载 2020-04-14 14:14:52 · 324 阅读 · 0 评论 -
argparse
1) argparse是python用于解析命令行参数和选项的标准模块,用于代替已经过时的optparse模块。例如 python parseTest.py input.txt output.txt --user=name --port=8080。使用步骤:1:import argparse2:parser = argparse.ArgumentParser()3:parser.ad...原创 2019-03-06 12:04:53 · 466 阅读 · 0 评论 -
Image Similarity Siamese Network
OverviewWith the kernel I am trying to run a simple test on using Siamese networks for similarity on a slightly more complicated problem than standard MNIST. The idea is to take a randomly initialized...转载 2018-03-27 20:56:49 · 735 阅读 · 0 评论 -
numpy einsum
What does einsum do?Imagine that we have two multi-dimensional arrays, A and B. Now let's suppose we want to...multiply A with B in a particular way to create new array of products; and then maybesum ...转载 2018-03-15 16:24:25 · 950 阅读 · 0 评论