pandas的使用
文章平均质量分 56
water_MLing
这个作者很懒,什么都没留下…
展开
-
python数组变整数
对于array格式的数组来说,numpy提供了一个方便的函数:np.trunc(arr)来执行取整操作A = np.array([[1.2,2.2,3.2,4.2],[5.2,6.2,7.2,8.2]])B = np.trunc(A)print(B)[[1. 2. 3. 4.][5. 6. 7. 8.]]C = B.astype(int)假如B是list,处理完以后要转换为list: D = C.tolist()...原创 2022-02-24 08:55:16 · 11269 阅读 · 0 评论 -
【python】Counter 函数的用法
“””https://docs.python.org/3.6/library/collections.html#collections.Counter原文链接:https://blog.csdn.net/u010339879/article/details/80036755Counter 是 dict 子类A counter tool is provided to support convenient and rapid tallies.提供计数器工具以支持方便快捷的计数。“”“ # Tall原创 2022-02-24 08:48:32 · 2967 阅读 · 0 评论 -
pandas函数read_csv()参数及例子
1. read_csv函数的定义pd.read_csv(filepath_or_buffer: ‘FilePathOrBuffer’,sep=<no_default>,delimiter=None,header=‘infer’,names=<no_default>,index_col=None,usecols=None,squeeze=False,prefix=<no_default>,mangle_dupe_cols=True,dtype: ‘原创 2022-02-23 17:11:54 · 2759 阅读 · 0 评论 -
tensorflwo2.0 (tf.GradientTape() )自定义模型的保存和提取
利用tf.GradientTape() 梯度带,保存模型.版权声明:本文为CSDN博主「hjxu2016」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。原文链接:https://blog.csdn.net/hjxu2016/article/details/105222369total_num = 25000#参数设置learning_rate = ...原创 2020-04-08 10:33:59 · 1125 阅读 · 0 评论 -
tensorlfow2.0 模型保存和导入
whole-model_saving(整个模型保存)You can save a model built with the Functional API into a single file. You can later recreate the same model from this file, even if you no longer have access to the code th...原创 2020-04-07 18:14:10 · 729 阅读 · 0 评论 -
tensorflow2.0保存模型和提取模型
1.保存节点 # 实例化Checkpoint,指定保存对象为model(如果需要保存Optimizer的参数也可加入) checkpoint = tf.train.Checkpoint(myModel=self.model) # ...(模型训练代码) # 模型训练完毕后将参数保存到文件(也可以在模型训练过程中每隔一段时间就保存一次) checkpoint.save(save_...原创 2020-04-06 20:34:28 · 1971 阅读 · 0 评论 -
tensorflow2.0 输出测试结果错误时的原因
数据格式定义非常重要,在调程序的时候要注意自己的数据定义, template = ('Epoch: {}, Train Loss: {}, Train Accuracy: {}, ' 'Test Loss: {}, Test Accuracy: {}') print( template.format(epoch, s...原创 2020-04-03 18:14:07 · 360 阅读 · 0 评论 -
learning_rate设置的问题
程序正确,loss = 3.00,精确不变问题这个问题是学习率设置的问题,数据过小,学习率设置过大会出现这个问题。动态设置学习率参数:def decay(epoch): if epoch < 10: return 0.001 if epoch >= 10 and epoch < 20: return 0.0001 if epo...原创 2020-04-03 10:47:26 · 809 阅读 · 0 评论 -
ValueError: Shape mismatch: The shape of labels (received (768,)) should equal the shape of logits e
tensorflow2.0 errorValueError: Shape mismatch: The shape of labels (received (768,)) should equal the shape of logits except for the last dimension (received (32, 24)).原因:解决:use of sparse_softmax_c...原创 2020-04-01 17:55:44 · 4605 阅读 · 0 评论 -
1.windows系统:
conda更新:conda update condaconda安装tensorflow:首先建立一个新的虚拟环境:1|conda create -n my_env python=3.6 #-n 也可以写全为 --name激活环境并安装tensorflow:1|activate my_env2|pip install tensorflow-退出环境1|deactivat...原创 2020-03-27 21:37:47 · 67 阅读 · 0 评论 -
list的操作
标题、Python列表操作的函数和方法列表操作包含以下函数:1、list.append(obj):在列表末尾添加新的对象2、list.count(obj):统计某个元素在列表中出现的次数3、list.extend(seq):在列表末尾一次性追加另一个序列中的多个值(用新列表扩展原来的列表)4、list.index(obj):从列表中找出某个值第一个匹配项的索引位置5、list.inse...原创 2020-03-22 09:50:28 · 193 阅读 · 0 评论 -
过滤器
过滤器1.Python 过滤器nums = [1, 2, 4, -1, 0, -8,9]nums = filter(lambda x:x>0, nums)print(list(nums))2.rolling()函数原创 2020-03-22 09:32:47 · 67 阅读 · 0 评论 -
pandas数据格式的转换
##1. 与numpy、series、list的转换1.将Pandas类型转换为numpy类型,通过.values来转换:np = pd.values2.将numpy类型转换为list类型,通过.tolist()方法转换:list = np.tolist()3.在用pandas包和numpy包对数据进行分析和计算时,经常用到DataFrame和array类型的数据。在对DataFra...原创 2020-03-22 06:48:06 · 2911 阅读 · 0 评论