莫烦tensorflow(9)-Save&Restore
import tensorflow as tf
import numpy as np
##save to file
#rember to define the same dtype and shape when restore
# W = tf.Variable([[1,2,3],[3,4,5]],dtype=tf.float32,name='Weights')
# b = tf.Variable([[1,2,3]],dtype=tf.float32,name='biases')
# init = tf.global_variables_initializer()
# saver = tf.train.Saver()
# with tf.Session() as sess:
# sess.run(init)
# save_path = saver.save(sess,"my_net/save_net.ckpt")
# print("save to path",save_path)
#resotre variables
#redefine the same shape and same type for your variables
W = tf.Variable(np.arange(6).reshape((2,3)),dtype=tf.float32,name='Weights')
b = tf.Variable(np.arange(3).reshape((1,3)),dtype=tf.float32,name='biases')
#not need init step
saver = tf.train.Saver()
with tf.Session() as sess:
saver.restore(sess,"my_net/save_net.ckpt")
print("Weights",sess.run(W))
print("biases",sess.run(b))
莫烦tensorflow(9)-Save&Restore的更多相关文章
- 莫烦tensorflow(8)-CNN
import tensorflow as tffrom tensorflow.examples.tutorials.mnist import input_data#number 1 to 10 dat ...
- 莫烦tensorflow(7)-mnist
import tensorflow as tffrom tensorflow.examples.tutorials.mnist import input_data#number 1 to 10 dat ...
- 莫烦tensorflow(6)-tensorboard
import tensorflow as tfimport numpy as np def add_layer(inputs,in_size,out_size,n_layer,activation_f ...
- 莫烦tensorflow(5)-训练二次函数模型并用matplotlib可视化
import tensorflow as tfimport numpy as npimport matplotlib.pyplot as plt def add_layer(inputs,in_siz ...
- 莫烦tensorflow(4)-placeholder
import tensorflow as tf input1 = tf.placeholder(tf.float32)input2 = tf.placeholder(tf.float32) outpu ...
- 莫烦tensorflow(3)-Variable
import tensorflow as tf state = tf.Variable(0,name='counter') one = tf.constant(1) new_value = tf.ad ...
- 莫烦tensorflow(2)-Session
import os os.environ['TF_CPP_MIN_LOG_LEVEL']='2' import tensorflow as tfmatrix1 = tf.constant([[3,3] ...
- 莫烦tensorflow(1)-训练线性函数模型
import tensorflow as tfimport numpy as np #create datax_data = np.random.rand(100).astype(np.float32 ...
- tensorflow学习笔记-bili莫烦
bilibili莫烦tensorflow视频教程学习笔记 1.初次使用Tensorflow实现一元线性回归 # 屏蔽警告 import os os.environ[' import numpy as ...
随机推荐
- php 固定红包 + 随机红包算法
<?php /** * 随机红包+固定红包算法[策略模式] * copyright (c) 2016 http://blog.csdn.net/CleverCode */ //配置传输数据DTO ...
- topcoder srm 590 div1 (max_flow_template)
problem1 link 对于每一个,找到其在目标串中的位置,判断能不能移动即可. problem2 link 如果最后的$limit$为$11=(1011)_{2}$,那么可以分别计算值为$(10 ...
- 浅谈HTTP中GET、POST用法以及它们的区别
浅谈HTTP中GET.POST用法以及它们的区别 HTTP定义了与服务器交互的不同方法,最基本的方法有4种,分别是GET,POST,PUT,DELETE.URL全称是资源描述符.我们可以这样认为: 一 ...
- 在Altium Designer 10中实现元器件旋转45°角放置
Tool--->Preferences >> PCB Editor >> General 将Rotation Step(旋转的步进值)由90改为45,这样以后每次按空格键 ...
- http随笔
1.什么是http? HTTP协议是Hyper Text Transfer Protocol(超文本传输协议)的缩写,是用于从WWW服务器传输超文本到本地浏览器的传送协议.它可以使浏览器更加高效,使网 ...
- ADC应用
数模转换(ADC)的应用笔记 智能时代,数字信号已体现在我们生活的方方面面,A/D,D/A是重要的基础.智能手机触摸信号需要转换为数字信号才能分辨触摸位置.数字去抖:打电话或者麦克风需要将模拟声信号转 ...
- RabbitMq(6) 如何保证消息不丢包
RabbitMQ一般情况很少丢失,但是不能排除意外,为了保证我们自己系统高可用,我们必须作出更好完善措施,保证系统的稳定性. 下面来介绍下,如何保证消息的绝对不丢失的问题,下面分享的绝对干货,都是在知 ...
- 【转】 RGB各种格式
转自:https://blog.csdn.net/LG1259156776/article/details/52006457?locationNum=10&fps=1 RGB组合格式 名字 ...
- Thread的中断机制(interrupt)
先看收集了别人的文章,全面的了解下java的中断: 中断线程 线程的thread.interrupt()方法是中断线程,将会设置该线程的中断状态位,即设置为true,中断的结果线程是死亡.还是等待新的 ...
- Canvas---clearRect()清除圆形区域
function clearArcFun(x,y,r,cxt){ //(x,y)为要清除的圆的圆心,r为半径,cxt为context var stepClear=1;//别忘记这一步 clearArc ...