
Tensorflow+Keras+python
以Tensorflow和Keras使用过程中遇到的问题为线索
一往无前的洋仔
这个作者很懒,什么都没留下…
展开
-
python 5种数据保存格式
jsonimport jsontxtf = open()f.write()f.close()csvimport pandasnpy或npz(二进制)import numpy as npnp.save或np.savez()pkl(二进制)import picklepickle.dump()原创 2022-01-07 14:23:23 · 1012 阅读 · 0 评论 -
1.Tensorflow计算图Graph
1.创建graph:# Rigester own graphg = tf.Graph()2. 往graph里添加操作节点op:默认往tensorflow自带的graph里添加op:# 这里已经包含了创建graph这一步,只不过用的是tf自带的graph# add ops to the default grapha = tf.constant(3)往我们自己注册的graph里添加op(包含步骤1):# 1.创建自己的graph(把graph的句柄赋给g)g = tf.Graph()#原创 2020-09-01 22:15:49 · 340 阅读 · 0 评论 -
主进程、子进程和守护进程
理解主进程main thread:程序执行的入口,可以理解为常用的main 函数。父进程parent thread:对于子进程而言, 子进程的创造者,可有多个子进程。 任何进程都有父进程,追根溯源是系统启动程序。对于我们一般写的程序,主进程是最初始的父进程。子进程child thread:相对父进程而言, 父进程创建的进程, 子进程只能对应一个父进程。如果没有标记为daemon , 则杀死父进程不会对子进程的运行状态有丝毫影响。守护进程daemon thread:即daemon thread原创 2020-08-30 21:39:59 · 3433 阅读 · 0 评论 -
关键字with、上下文管理器context manager
上下文管理器:定义(根据本人理解):一个按照上下文管理协议定义的类Class实例化之后得到的对象,上下文管理协议要求包含两个方法__enter__和__exit__。the object is an instance of a class defined according to the context manager protocol that consists of enter and exit methods.应用:资源(比如文件)的获取及释放,异常处理。关键字with:语法格式syntax原创 2020-08-24 16:52:37 · 657 阅读 · 0 评论 -
打开tensorboard报错
文件名太长可能导致tensoboard打开失败原创 2020-05-14 21:10:21 · 212 阅读 · 0 评论 -
添加自定义数据到TensorBoard显示
tf.scalar_summary(tags, values)# ...summary_op = tf.summary.merge_all() #向计算图中添加记录节点summary_writer = tf.summary.FileWriter(logdir, graph=sess.graph)summary_str = sess.run(summary_op) #运行记录节点summary_writer.add_summary(summary_str, global_step) #将运行结果写入转载 2020-05-14 17:58:44 · 373 阅读 · 0 评论 -
静态方法@staticmethod
@staticmethod静态方法:既不需要访问实例属性、方法,也不需要访问类属性、方法,通过类调用的格式为classname.staticmethod,可以不传入self,可在类内部使用;原创 2020-05-09 11:29:11 · 915 阅读 · 0 评论 -
tf.Summary
可用tf.Summary自定义自己的google_protocol_buffer以防止验证集过大而报错参见https://www.jianshu.com/p/39c652f63b4d转载 2020-05-09 10:30:44 · 134 阅读 · 0 评论 -
with tf.variable_scope():或with tf.name_scope():
keyword:with 用于上下文管理,共享变量控制参数reuse取true,则作用域内可重用,否则不可重用,智能一点的话取tf.AUTO_REUSE:如果创建过就返回,没有创建过就创建一个新的变量返回至于tf.name_scope和tf.variable_scope详情见下面URL:https://www.imooc.com/article/22966https://www.cnblo...原创 2020-05-08 15:21:52 · 2848 阅读 · 0 评论 -
occur error: __init__() got multiple values for argument ‘activation‘ when using tf.layers.dense
a solution can be found at原创 2020-04-29 15:01:31 · 1937 阅读 · 1 评论