![](https://img-blog.csdnimg.cn/20201014180756913.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Python
YUAnthony
这个作者很懒,什么都没留下…
展开
-
Python+PEP8 | VSCode自动格式化代码
PEP8 coding style原创 2022-05-09 18:04:30 · 4118 阅读 · 0 评论 -
Python: dict vs defaultdict
default 相较于 dict 的好处在于当字典的 key 不存在但被查询时返回一个默认值而不是报错from collections import defaultdictdict1 = defaultdict(int)dict2 = defaultdict(set)dict3 = defaultdict(str)dict4 = defaultdict(list)dict1[2] ='two'print(dict1[1])print(dict2[1])print(dict3[1])p原创 2022-04-24 21:03:42 · 1042 阅读 · 0 评论 -
Python 数组的值传递方法
Python 对数组等对象拷贝默认采用的方法是引用传递,即地址传递,修改拷贝的值的时候原对象也会随之改变。如:origin = np.array([1,1,2,2,3,3,4,5])filter_arr = [1,2,3]for i in range(3): temp = origin print(origin) print(temp) temp[temp!=filter_arr[i]] = 0 print(temp) print('-原创 2021-02-14 23:51:41 · 4687 阅读 · 0 评论 -
输出 tensor object 的值
今天早上我想通过获得两张图片的 dice coefficient 值score = dice_coef(prediction[1],groundTruth[1])print(score)print 的结果却是这样的信息tf.Tensor(0.7923989514988125, shape=(), dtype=float64)那么如何直接输出 0.7923989514988125 这个值呢?在此之前我们先研究下 Tensor 是个什么东西。TensorFlow 是一个定义和运行张量计算的框架。张原创 2021-02-10 13:38:20 · 751 阅读 · 1 评论 -
Python reshape() 函数用法
reshape()函数用于在不更改数据的情况下为数组赋予新形状。原创 2020-06-07 19:36:10 · 108851 阅读 · 3 评论