← Tags

#python

16 posts

UV

As another tool for Python, uv is written by rust and provides integrated experience, e.g. interpretor management (by uv python) virtual environment manangement (by uv venv) package management (by uv …

Concurrent Python

Python has 2 builtin concurrent utilities which is widely utilized, i.e., process pool and thread pool, dedicated to CPU intensity and I/O intensity respectively. Due to global interpreter lock …

Argument Parser

Package argparse is a convenient utility for argument parsing, in which class ArgumentParser is defined. Concerning its usage, a simple example can be given as follows. from argparse import …

Virtual Environment

Python的虚拟环境(virtual environment)是一个独立的Python运行环境。在一个独立的环境中,可以正常安装所需要的数据包(如使用pip等)。既不受系统环境的影响,也不会对系统环境产生影响。具体地,创建虚拟环境就是把系统Python环境复制到所创建的独立环境中。当进入一个虚拟环境时,virtualenv会修改相关的环境变量,让python和pip指向当前的独立环境。 创建独 …

A TDoc Processor

Introduction In order to facilitate the tdoc. related processing, I wrote a simple module using Python, termed tdoc, based on Builtin modules, os, functools, multiprocessing, argparse; and 3rd party …

QAM

Introduction In order to structure the utility relating to constellation modulation, I wrote a class Quadrature_Amplitude_Modulation in Python. Source code import numpy as np import matplotlib.pyplot …

Matplotlib

Background Matplotlib is a popular python package for figure plot and data visualization. Installation pip install matplotlib Submodules Matplotlib comes with a series of submodules, e.g., …

Data Type

Python中的大部分对象,如列表、字典、 Numpy 数组都是可变对象,大多数用户定义的类型(类)也是可变的。可变对象中包含的对象和值是可以被修改的。但是有一些对象是不可变的,如字符串、元组。 标量 Python的标准库中有一个小的内建类型集合,用来处理数值、字符串、布尔值以及日期和时间。这类“单值”类型被称为标量。主要的标量类型有 int1 前缀 0x 表示16进制整数。 整数除法会把结果自 …

Pytorch Lightning

Pytorch Lightning is a high level framework and encapsulation on top of pytorch, which provides simplified interfaces and elegant code structure relating to AI. Detailed usage can be found in its …

Functions in Python

在Python中,函数通过关键字 def 定义。 参数 从函数的角度,parameter指函数定义圆括号内的变量列表,而argument指当函数被调用时传递的值。 Parameter 变长参数(variable-length) 参数名前加 * 可以表示该参数可以接受任意数目的位置参数。这种情况下,函数会接受元组参数(a tuple of arguments)。以 * 开头的参数只能以最后一个位置 …

Einops

Einstein-inspired notation for operations (Einops1) is a python package which provides extremely flexible and powerful opertions on tensors, e.g., permuting/reordering, reshaping (combining and …

Tensorflow

Introducation Tensorflow is a deep learning library, which provides two programming interfaces, C++ and Python. Moreover, The Python API integrates very well with numpy. In many places, Tensorflow …

Pytorch

张量 在pytorch中,神经网络的输入、输出、以及网络的参数等都采用了“张量”的数据结构。张量与numpy中的多维数组(numpy.ndarray)非常类似,区别在于张量可以在GPU或其他硬件上运行。 成员函数名称末尾加上 _ ,会采用替换模式,也即该成员函数直接修改张量对象本身。 .item() 返回其具体数值,该方法仅适用于大小为1(也即只含有一个元素)的张量。 .view() 功能为 …

Pandas

Pandas 支持大部分 numpy 语言风格的数组计算。尽管代码风格相似,但最大的不同在于前者是用来处理表格或不同类型数据的,而后者更适合处理相同类型数据的。 数据结构 Series Series 是一维数组的对象,包含 index 序列和 values 序列,分别可以通过对象的 index 和 values 属性获得。 通常需要创建一个index序列来标识每个数据点。如果不显式指定,那么默认 …

Python - Fundamental

Python解释器 Python程序运行时,需要Python解释器去执行 .py 文件。下面是一些常见的Python解释器。 CPython 当Python安装好之后,CPython解释器就已经安装好了。该解释器是用C语言开发的,所以被称为CPython。在终端执行 python 命令后启动的就是该解释器。 PyPy PyPy解释器采用JIT技术对Python程序代码进行动态编译,所以PyPy以 …

Package Management

Introduction One of the most charmful characters of Python is its a rich number of packages. Accordingly, package managers emerge, e.g., pip, setuptools. This post just briefly introduce the usage of …