前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >好用的函数,assert,random.

好用的函数,assert,random.

作者头像
py3study
发布2020-01-17 11:45:07
5770
发布2020-01-17 11:45:07
举报
文章被收录于专栏:python3

python 中好用的函数,random.sample等,持续更新

random.sample

   random.sample的函数原型为:random.sample(sequence, k),从指定序列中随机获取指定长度的片断。sample函数不会修改原有序列

代码语言:javascript
复制
import random
list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
slice = random.sample(list, 5)  # 从list中随机获取5个元素,作为一个片断返回
print(slice)
print(list)# 原有序列并没有改变
[1, 8, 7, 6, 4]
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

seaborn tsplot

学习参考链接:官方说明博客总结

Pandas的DataFrame常常和tsplot搭配使用,DataFrame的用法以及构造数组的具体例子参考博客

最简单的时序折线图绘制见参考例子。更多关于参数unit,direction,time的使用暂时还没有弄明白,后续补充。

和plot相比最大的好处就是可以画出平均线,比如对比两种方法的性能,每一种方法有100条结果,用tsplot可以直观对比平均线。

 tensorflow.python.platform flags 标志的使用

学习参考链接:tensorflow命令行参数原理详细解析以及实例

python assert的作用

学习参考链接:python assert的作用简单的例子

python dir(对象)

dir() 是一个内置函数,用于列出对象的所有属性及方法。

reuse_variables()的用法

参考莫凡python,以及下列示意性代码

代码语言:javascript
复制
 with tf.variable_scope('model', reuse=None) as training_scope:
    print(dir(self))
    if 'weights' in dir(self):
        training_scope.reuse_variables()
        weights = self.weights
    else:
        # Define the weights
        self.weights = weights = self.construct_weights()

tf.assign()、tf.assign_add()的用法

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2019/05/20 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • python 中好用的函数,random.sample等,持续更新
    • random.sample
      • seaborn tsplot
        •  tensorflow.python.platform flags 标志的使用
          • python assert的作用
            • python dir(对象)
              • reuse_variables()的用法
              领券
              问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档