- 博客(13)
- 收藏
- 关注
原创 python一些好例子来快速获得技能
Unpacking Elements first, *others = (1,2,3,4) first, *middle, last = (1,2,3,4) name, email, *phone_numbers = ('Jack', 'jack@gmail.com', '1234567', '122333') Keeping the last N items collections.deque(maxlen=5) Finding the largest or smallest N items.
2021-03-28 21:53:57
94
原创 python中的descriptor
what is a descriptor? Three behaviors for an attribute of an object: read set delete Desctiptor is a hook when accessing an attribute Demo class Book(object): def __init__(self): self._page = 0 @property def page(self): return
2021-03-07 22:46:23
110
原创 python的闭包和装饰器
closure https://www.programiz.com/python-programming/closure def get_config_table(): cfg = {'a':1, 'b':2} return cfg def get_config_index(): config_table = get_config_table() def wrapper(cfg_name): return config_table.get(cfg_name,
2021-03-07 22:44:40
120
1
原创 python的profiling和如何运行更快初探
Profile Solution Use time tool [willchen@dn121201 cProfile]$ /usr/bin/time -v python test.py Command being timed: "python test.py" User time (seconds): 1.17 System time (seconds): 0.14 Percent of CPU this job got: 56% Elapsed (wall clock) time (h:
2021-03-07 22:41:57
131
原创 python中的meta初探
Table of Contents 1 About Meta1.1 type & object & class & instance1.1.0.1 instance's class1.1.0.2 class's class and parents1.1.0.3 type's parent1.2 __call__'s role in class and t
2021-03-07 22:39:22
1175
1
原创 python中的反射和自省
Introspection examine something, typically an object, at runtime. dir() dir(object) ['__class__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__',
2021-03-07 22:36:42
106
原创 python解释器初探
Usages run python file python test.py run a module -m: module python -m pdb test.py python -m pydoc -p 9000 input from stdin (base) PS C:\> python Python 3.7.4 (default, Aug 9 2019, 18:34:13) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win
2021-03-07 22:34:37
214
原创 python中的help
built-in help() import tensorflow as tf help(tf) Help on package tensorflow: NAME tensorflow - TensorFlow root package PACKAGE CONTENTS DATA __compiler_version__ = 'MSVC 191627035' __cxx11_abi_flag__ = 0 __git_version__ = 'unknown'
2021-03-07 22:30:23
93
原创 python中的并发
Table of Contents 1 Concurrency2 When is concurrency usefule2.1 Summary3 How to improve3.1 Synchronous Version3.2 Threading Version3.2.1 What it looks like3.2.2 downsid
2021-03-07 22:21:49
169
原创 一些python3比较有用的特性
What’s new in python There are so many new things in Python3.8.2(can be several books), only go through and pick something interesting to introduce here. Summary from Python3.8.2 documentation What’s New In Python 3.0 compared to 2.6 Print Is A Function
2021-03-07 22:19:52
167
原创 深入理解Python的class
Table of Contents 1 Definition1.1 1.MRO1.1.1 A Demo1.2 2.Determining the appropriate metaclass1.3 3.Preparing the class namespace1.4 4.Executing the class body1.5 5.Creating the c
2021-03-07 22:15:41
243
1
原创 Active Learning的简介
解决什么问题 数据标记有时候是个大问题,几百,几千,几万,十万,百万,千万的数据要一一标注的成本非常高。 引入active learning,是希望能减少数据标注的量。 是什么? 训练的数据不是一开始全部给,而是选择比较有用的数据,慢慢动态地增加,如上图。 原理 一句话,就是训练数据对模型的贡献程度不同,尽量挑选那些关键的数据。比如上图平面的点分类问题,只需要在中间间隔的数据就够了,而明显在2边的数据则对我们的分割线没啥帮助。 如何做 重点在数据的选择方法,常用的有如下方法: Least Conf
2020-10-19 09:15:52
663
原创 几种python debugger简介
PDB Refer to: https://docs.python.org/3/library/pdb.html a python module so can be executed by python -m pdb <source_file> Usage python -m pdb <source_file> actually call Pdb()._runscript(source_file) insert by code:import pdb pdb.set_tra
2020-10-15 10:51:15
683
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人