<?xml version="1.0" encoding="utf-8" ?><rss version="2.0"><channel><title><![CDATA[老码侬的博客]]></title><description><![CDATA[]]></description><link>https://blog.csdn.net/chendawei1987</link><language>zh-cn</language><generator>https://blog.csdn.net/</generator><copyright><![CDATA[Copyright &copy; chendawei1987]]></copyright><item><title><![CDATA[L1和L2范数]]></title><link>https://blog.csdn.net/chendawei1987/article/details/122646623</link><guid>https://blog.csdn.net/chendawei1987/article/details/122646623</guid><author>chendawei1987</author><pubDate>Sun, 23 Jan 2022 02:19:06 +0800</pubDate><description><![CDATA[L1、L2范数详解]]></description><category></category></item><item><title><![CDATA[anaconda3 环境配置及tensorflow安装]]></title><link>https://blog.csdn.net/chendawei1987/article/details/119842378</link><guid>https://blog.csdn.net/chendawei1987/article/details/119842378</guid><author>chendawei1987</author><pubDate>Sat, 21 Aug 2021 23:13:13 +0800</pubDate><description><![CDATA[conda常用指令
conda info查看当前conda的主要信息
conda info --envs查看环境列表
conda activate your_env_name  激活环境
conda deactivate 退出当前环境
conda create --name your_env_name python=3.6 numpy pandas 创建带指定包的环境
conda remove --name your_env_name --all 移除环境，注意当前anaconda3/envs文件夹里的文件]]></description><category></category></item><item><title><![CDATA[Python编程之pdb & cProfile]]></title><link>https://blog.csdn.net/chendawei1987/article/details/119149467</link><guid>https://blog.csdn.net/chendawei1987/article/details/119149467</guid><author>chendawei1987</author><pubDate>Tue, 27 Jul 2021 20:04:12 +0800</pubDate><description><![CDATA[调试方法

print：可以在需要的地方加打印信息，观察打印结果是否符合预期，用于排查错误。这种方式每次添加打印信息都需要重新运行程序，因此适用于小型程序，即启动重新运行不需要花费太长时间。
IDE 断点：在开发环境中（如pycharm）编写代码，可以在语句中添加断点，代码运行到断点处暂停，用于观察断点处的环境信息是否符合预期，这也是最有效的debug方法。
pdb：在没有开发环境，只能用命令行来debug的时候（Jupyter）可以用pdb，使用方法：
要启动 pdb 调试，只需要在程序中，加入“impo]]></description><category></category></item><item><title><![CDATA[Python编程之单元测试]]></title><link>https://blog.csdn.net/chendawei1987/article/details/119145914</link><guid>https://blog.csdn.net/chendawei1987/article/details/119145914</guid><author>chendawei1987</author><pubDate>Tue, 27 Jul 2021 16:07:34 +0800</pubDate><description><![CDATA[单元测试的基础是代码模块化，模块之间的耦合度尽量低，每个模块实现的功能尽可能独立。一般代码结构都是由底到上的树形结构，单元测试也应该由底层开始，逐渐到上层。
单元测试的过程就是模拟可能的输入，观察输出是否符合预期，通常使用 assertEqual()、assertTrue()、assertFalse() 和 assertRaise() 等 assert 语句对结果进行验证。
Magic Mock
如果被测试的模块中有一些依赖项，则需要用虚假实现的方式，替换掉这些依赖项，一般用unit test包里面的moc]]></description><category></category></item><item><title><![CDATA[Python编程技巧（八）—— 编程规范]]></title><link>https://blog.csdn.net/chendawei1987/article/details/119137896</link><guid>https://blog.csdn.net/chendawei1987/article/details/119137896</guid><author>chendawei1987</author><pubDate>Tue, 27 Jul 2021 15:37:40 +0800</pubDate><description><![CDATA[空行
PEP 8 规定，全局的类和函数的上方需要空两个空行，而类的函数之间需要空一个空行。函数内部也可以使用空行，用来区分不同意群之间的代码块。但是最多空一行。
代码的尾部，每个代码文件的最后一行为空行，并且只有这一个空行。
空格
调用函数的参数列表中会出现逗号，请注意逗号后要跟一个空格；
冒号经常被用来初始化字典，冒号后面也要跟一个空格；
使用#进行单独注释，要在#后、注释前加一个空格；
操作符，例如+，-，*，/，&amp;，|，=，==，!=，在两边都保留空格。不过与此对应，括号内的两端并不需要空格。]]></description><category></category></item><item><title><![CDATA[Python编程技巧（七）—— 并发多线程]]></title><link>https://blog.csdn.net/chendawei1987/article/details/119120659</link><guid>https://blog.csdn.net/chendawei1987/article/details/119120659</guid><author>chendawei1987</author><pubDate>Mon, 26 Jul 2021 23:08:04 +0800</pubDate><description><![CDATA[并发，通过线程和任务之间互相切换的方式实现，但同一时刻，只允许有一个线程或任务执行。而并行，则是指多个进程同时执行。
并发通常用于 I/O 操作频繁的场景，而并行则适用于 CPU heavy 的场景。
例：
import concurrent.futures
import requests
import threading
import time

def download_one(url):
    resp = requests.get(url)
    print('Read {} from {}'.]]></description><category></category></item><item><title><![CDATA[Python编程技巧（六）—— 协程]]></title><link>https://blog.csdn.net/chendawei1987/article/details/119120413</link><guid>https://blog.csdn.net/chendawei1987/article/details/119120413</guid><author>chendawei1987</author><pubDate>Mon, 26 Jul 2021 22:52:01 +0800</pubDate><description><![CDATA[协程为单线程；协程由用户决定，在哪些地方交出控制权，切换到下一个任务。
协程的写法更加简洁清晰，把 async / await 语法和 create_task 结合来用，对于中小级别的并发需求已经毫无压力。
写协程程序的时候，你的脑海中要有清晰的事件循环概念，知道程序在什么时候需要暂停、等待 I/O，什么时候需要一并执行到底。
例1：
生产者消费者模型：

import asyncio
import random

async def consumer(queue, id):
    while True.]]></description><category></category></item><item><title><![CDATA[Python编程技巧（五）—— 容器、迭代器、生成器]]></title><link>https://blog.csdn.net/chendawei1987/article/details/119115827</link><guid>https://blog.csdn.net/chendawei1987/article/details/119115827</guid><author>chendawei1987</author><pubDate>Mon, 26 Jul 2021 19:07:21 +0800</pubDate><description><![CDATA[容器
容器可以很直观地想象成多个元素在一起的单元，而不同容器的区别，正是在于内部数据结构的实现方法。列表（list: [0, 1, 2]），元组（tuple: (0, 1, 2)），字典（dict: {0:0, 1:1, 2:2}），集合（set: set([0, 1, 2])）都是容器。
迭代器iterator
每一个容器都是可迭代的。迭代器（iterator）提供了一个 next 的方法。调用这个方法后，要么得到这个容器的下一个对象，要么得到一个 StopIteration 的错误。不需要像列表一样指定]]></description><category></category></item><item><title><![CDATA[Python编程技巧（四）—— YAML]]></title><link>https://blog.csdn.net/chendawei1987/article/details/119113022</link><guid>https://blog.csdn.net/chendawei1987/article/details/119113022</guid><author>chendawei1987</author><pubDate>Mon, 26 Jul 2021 17:30:27 +0800</pubDate><description><![CDATA[序列号与逆序列化工具
YAML是Python常用的工具，可以方便地序列化 / 逆序列化Python结构数据。
逆序列化：yaml.load()
将文件内容转换为python结构数据，如list, dict等
yaml.load("""
... - Hesperiidae
... - Papilionidae
... - Apatelodidae
... - Epiplemidae
... """)

['Hesperiidae', 'Papilionidae', 'Apatelodidae', 'Epipl]]></description><category></category></item><item><title><![CDATA[Python编程技巧（三）—— 装饰器]]></title><link>https://blog.csdn.net/chendawei1987/article/details/119106884</link><guid>https://blog.csdn.net/chendawei1987/article/details/119106884</guid><author>chendawei1987</author><pubDate>Mon, 26 Jul 2021 15:48:37 +0800</pubDate><description><![CDATA[Decorators is to modify the behavior of the function through a wrapper so we don’t have to actually modify the function.
所谓的装饰器，其实就是通过装饰器函数，来修改原函数的一些功能，使得原函数不需要修改。
def my_decorator(func):
    def wrapper():
        print('wrapper of decorator')
        fun]]></description><category></category></item><item><title><![CDATA[Python注意事项（二）—— 变量与对象]]></title><link>https://blog.csdn.net/chendawei1987/article/details/119104723</link><guid>https://blog.csdn.net/chendawei1987/article/details/119104723</guid><author>chendawei1987</author><pubDate>Mon, 26 Jul 2021 11:04:35 +0800</pubDate><description><![CDATA[Python中要区分两个概念，变量和对象，对象是在内存中开辟的一块区域，变量指向这块区域，当变量间直接赋值时，等同于两个变量指向同一个对象即同一块区域。变量可以被删除，对象只能通过垃圾回收机制回收。
在C和C++等语言中，参数传递通常分为值传递和引用传递，值传递是直接赋值，被传递的参数修改不影响原变量，引用传递是传递变量指针，被传递的参数修改影响原变量。
但是在Python中不做区分，只有一种方式，就是通过直接赋值来传递参数，直接赋值之后两个变量指向同一个对象，如果修改两个变量中的任一个导致了对象改变，则另]]></description><category></category></item><item><title><![CDATA[Python注意事项（一）—— 拷贝与比较]]></title><link>https://blog.csdn.net/chendawei1987/article/details/119040134</link><guid>https://blog.csdn.net/chendawei1987/article/details/119040134</guid><author>chendawei1987</author><pubDate>Fri, 23 Jul 2021 17:31:10 +0800</pubDate><description><![CDATA[copy &amp; deepcopy
import copy
l1 = [1, 2, 3]
l2 = copy.copy(l1)
l3 = copy.deepcopy(l1)

浅拷贝就是对原对象中子对象的引用，如果原对象中增加新的子对象，对拷贝后的对象没有影响，但是如果原来的子对象变化，则拷贝后的对象中的子对象也会跟着变化。如：
l1 = [[1, 2], (30, 40)]
l2 = list(l1)
l1.append(100)
l1[0].append(3)

l1
[[1, 2, 3], (30]]></description><category></category></item><item><title><![CDATA[西瓜书学习笔记—决策树]]></title><link>https://blog.csdn.net/chendawei1987/article/details/112790473</link><guid>https://blog.csdn.net/chendawei1987/article/details/112790473</guid><author>chendawei1987</author><pubDate>Thu, 22 Jul 2021 18:24:10 +0800</pubDate><description><![CDATA[决策树是根据数据样本的各个属性及其取值和特殊的判断条件来把样本分类的算法模型。

主要有ID3决策树（Iterative Dichotomiser迭代二分类器），CART决策树。

信息熵：是度量数据中包含信息多少的重要指标，信息熵越小，则代表该数据集中包含的数据信息越少，信息纯度越高。

计算公式：Ent(D) = -sum(pi*log2(pi)), pi代表第i类样本在总样本中的占比，这里的类是根据label的分类, D为总的数据集。

信息增益：

Gain(D, a) = Ent(D) - sum]]></description><category></category></item><item><title><![CDATA[Python学习笔记之基础知识——import]]></title><link>https://blog.csdn.net/chendawei1987/article/details/119005685</link><guid>https://blog.csdn.net/chendawei1987/article/details/119005685</guid><author>chendawei1987</author><pubDate>Thu, 22 Jul 2021 18:16:58 +0800</pubDate><description><![CDATA[用法
from file import func/class

这种导入方式可以直接使用func/class
file不用加后缀，如果不在同一个目录，还要加上路径
import sys
sys.path.append("..")

上面这条语句表示将当前程序所在位置向上提了一级。
import file

如果用这种导入方式，则在使用时要加上file.func()
注意：
在做项目的时候，以项目的根目录作为最基本的目录，所有的模块调用，都要通过根目录一层层向下索引的方式来 import。在pycharm中已]]></description><category></category></item><item><title><![CDATA[Python学习笔记之基本语法——类]]></title><link>https://blog.csdn.net/chendawei1987/article/details/118993486</link><guid>https://blog.csdn.net/chendawei1987/article/details/118993486</guid><author>chendawei1987</author><pubDate>Thu, 22 Jul 2021 10:56:58 +0800</pubDate><description><![CDATA[定义
class name(parent): # 父类parent可以有或者没有
	def __init__(self, para1, para2...):
		parent.__init__(self, para) / super().__init__(self, para) 
		# 用super召唤父类的构造函数可以保证父类的初始化只执行一次，即使有多个子类继承同一个父类
		statement
		....
	def func(self, para):
		statement
		....

Nam]]></description><category></category></item><item><title><![CDATA[Python学习笔记之基本语法——匿名函数与函数式编程]]></title><link>https://blog.csdn.net/chendawei1987/article/details/118971019</link><guid>https://blog.csdn.net/chendawei1987/article/details/118971019</guid><author>chendawei1987</author><pubDate>Wed, 21 Jul 2021 17:36:51 +0800</pubDate><description><![CDATA[匿名函数
lambda argument1, argument2,... argumentN : expression

例如：
square = lambda x: x**2
square(3)

9

匿名函数可以作为函数的参数，如：
l = [(1, 20), (3, 0), (9, 10), (2, -1)]
l.sort(key=lambda x: x[1]) # 按列表中元组的第二个元素排序
print(l)
# 输出
[(2, -1), (3, 0), (9, 10), (1, 20)]

也]]></description><category></category></item><item><title><![CDATA[Python学习笔记之基本语法——自定义函数]]></title><link>https://blog.csdn.net/chendawei1987/article/details/118967987</link><guid>https://blog.csdn.net/chendawei1987/article/details/118967987</guid><author>chendawei1987</author><pubDate>Wed, 21 Jul 2021 16:25:21 +0800</pubDate><description><![CDATA[自定义函数
声明/定义与调用
在调用自定义的函数之前，要先定义或者声明，
def func(param): 
	statement 
	return value
func(param)

但是，如果我们在函数内部调用其他函数，函数间哪个声明在前、哪个在后就无所谓，因为 def 是可执行语句，函数在调用之前都不存在，我们只需保证调用时，所需的函数都已经声明定义：
def my_func(message):
    my_sub_func(message) # 调用my_sub_func()在其声明之前不影响程]]></description><category></category></item><item><title><![CDATA[Python学习笔记之基本语法——异常处理]]></title><link>https://blog.csdn.net/chendawei1987/article/details/118962818</link><guid>https://blog.csdn.net/chendawei1987/article/details/118962818</guid><author>chendawei1987</author><pubDate>Wed, 21 Jul 2021 12:13:14 +0800</pubDate><description><![CDATA[异常处理
处理方法
try … except …
try:
    s = input('please enter two numbers separated by comma: ')
    num1 = int(s.split(',')[0].strip())
    num2 = int(s.split(',')[1].strip())
    ...
except ValueError as err:
    print('Value Error: {}'.format(err))
except I]]></description><category></category></item><item><title><![CDATA[Python学习笔记之基本语法——循环遍历]]></title><link>https://blog.csdn.net/chendawei1987/article/details/118945517</link><guid>https://blog.csdn.net/chendawei1987/article/details/118945517</guid><author>chendawei1987</author><pubDate>Tue, 20 Jul 2021 22:13:34 +0800</pubDate><description><![CDATA[基本语法
循环遍历
for item in &lt;iterable&gt;:
    ...

只要是可迭代的数据结构，都可以用这种方式循环遍历。
对于字典：
默认字典的键是可迭代的，用dict.values()可以遍历字典的值，用dict.item()可以遍历字典的键值对。
d = {'name': 'jason', 'dob': '2000-01-01', 'gender': 'male'}
for k in d: # 遍历字典的键
    print(k)
name
dob
gender

for ]]></description><category></category></item><item><title><![CDATA[Python学习笔记之基础语法--input & outpupt & json]]></title><link>https://blog.csdn.net/chendawei1987/article/details/118939548</link><guid>https://blog.csdn.net/chendawei1987/article/details/118939548</guid><author>chendawei1987</author><pubDate>Tue, 20 Jul 2021 21:18:45 +0800</pubDate><description><![CDATA[基本语法
命令行输入输出
name = input('your name:')
gender = input('you are a boy?(y/n)')

###### 输入 ######
your name:Jack
you are a boy?

welcome_str = 'Welcome to the matrix {prefix} {name}.'
welcome_dic = {
    'prefix': 'Mr.' if gender == 'y' else 'Mrs',
    'name]]></description><category></category></item></channel></rss>