
Python类
文章平均质量分 78
lucky_chaichai
爱学习的仙女,都是一些基础知识随笔、总结哦,good good study,day day up~噢耶
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
paddlenlp调用ERNIE、使用ERNIEKIT
paddle and paddlenlp原创 2022-12-28 16:45:12 · 2134 阅读 · 5 评论 -
Python与多进程、多线程——multiprocessing、threading、async/await
1、multiprocessing模块1)使用进程池pool:pool( )类:指定进程池中同时执行的进程数为8,当一个进程执行完毕后,如果还有新进程等待执行,则会将其添加进去。pool.apply_async( ):为非阻塞,即不用等待当前运行的子进程执行完毕(各子进程并行执行,且主进程与子进程之间、各子进程之间都不会互相等待),随时根据系统调度来进行进程切换。pool.apply( ):阻塞型,各子进程需依次执行,主进程会被阻塞直到函数执行结束【多进程执行过程中,子进程出错时,将直接跳出,执原创 2022-04-21 10:12:37 · 1674 阅读 · 0 评论 -
pytorch(版本1.9.0+cpu)学习实践
目录一、一些基本操作一、一些基本操作# 随机初始化一个tensorrand_num=torch.rand(2,3) print(rand_num) # tensor([[0.8485, 0.8955, 0.6221],[0.7218, 0.6770, 0.5296]])# 直接使用数据构建一个tensortensor_fromLis=torch.tensor([[2,3],[5,6],[4,4]]) print(tensor_fromLis) # tensor([[2, 3],[5, 6]原创 2021-07-23 09:58:51 · 2909 阅读 · 0 评论 -
(词/位置)向量训练实战——Word2vector、Glove、Doc2vector、position_embedding
1、基于gensim(版本:3.8.3)的Word2vector进行token2id,方便后续利用word2vector进行embeddingimport pprintimport gensimfrom gensim.models.word2vec import Word2Vecfrom gensim.corpora.dictionary import Dictionarysentense='按我的理解,优化过程的第一步其实就是求梯度。这个过程就是根据输入的损失函数,提取其中的变量,进行梯度下降原创 2022-01-21 10:01:25 · 3941 阅读 · 0 评论 -
Python中的排列组合
itertools模块1、permutations:排列,考虑顺序>>> from itertools import permutations>>> rc=permutations(['a','b','c'],3)>>> list(rc)[('a', 'b', 'c'), ('a', 'c', 'b'), ('b', 'a', 'c'), ('b', 'c', 'a'), ('c', 'a', 'b'), ('c', 'b', 'a')]2原创 2021-06-29 11:13:32 · 338 阅读 · 0 评论 -
tkinter模块生成消息弹窗
tkinter模块 是Python 的标准 GUI 库1)提示框生成包括各种提示框:消息提示框(showinfo())、错误(showerror())、警告(showwarning())等,以消息提示框为例:# Python3import tkinterimport tkinter.messageboxtop = tkinter.Tk()top.withdraw() # ****实现主窗口隐藏(即隐藏带tk标题的空白窗口)top.update() # *********需要update原创 2021-03-10 15:28:45 · 2821 阅读 · 1 评论 -
TensorFlow2(版本2.5.0)学习笔记(含keras_bert、W2V)
1、设置CPU/GPU运行环境:指定使用CPU:import tensorflow as tftf.debugging.set_log_device_placement (True) # 设置输出运算所在的设备cpus = tf.config.list_physical_devices ('CPU') # 获取当前设备的 CPU 列表tf.config.set_visible_devices (cpus) # 设置TensorFlow的可见设备范围为cpu2、tf定义变量原创 2021-02-03 14:20:26 · 4842 阅读 · 3 评论 -
爬虫中的“句柄无效”错误和selenium.common.exceptions.ElementClickInterceptedException
1.使用selenium爬虫报错:OSError: [WinError 6] 句柄无效原因:多次爬虫后没有成功关闭chromedriver.exe,导致后台含有多个chromedriver.exe 进程。解决: 爬虫程序结束后使用driver.quit()2.使用selenium爬虫时,find到的元素在click时报错:selenium.common.exceptions.ElementClickInterceptedException具体错误信息:selenium.common.excepti原创 2020-12-30 17:07:39 · 963 阅读 · 6 评论 -
Python 中的 修饰符(@classmethod,@property)
Python类中,@ classmethod 修饰符对应的函数不需要实例化,不需要 self 参数,但第一个参数需要是表示自身类的 cls 参数,以用来调用类的属性,类的方法,实例化对象等。但是在类的其他函数中调用时依然需要用self,如下类:class ToMysql: def __init__(self, sql_host, sql_user, sql_passwd,sql_db_name): self.sql_connect=pymysql.connect(host=sql原创 2020-12-22 16:32:43 · 2370 阅读 · 0 评论