tf_upgrade_v2.exe实验

Posted 2008nmj

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了tf_upgrade_v2.exe实验相关的知识,希望对你有一定的参考价值。

实验前

import tensorflow as tf
import numpy as np
#create data
x_data=np.random.rand(100).astype(np.float32)
y_data=x_data*0.1+0.3
###create tensorflow structure start###
Weights = tf.Variable(tf.random_uniform([1],-1.0,1.0))
biases = tf.Variable(tf.zeros([1]))
y=Weights*x_data+biases
loss = tf.reduce_mean(tf.square(y-y_data))
optimizer = tf.train.GradientDescentOptimizer(0.5)
###create tensorflow structure end###
train = optimizer.minimize(loss)
init = tf.initialize_all_variables()
sess = tf.Session()
sess.run(init)
for step in range(201):
    sess.run(train)
    if step % 20 == 0:
        print(step, sess.run(Weights), sess.run(biases))

实验后:

import tensorflow as tf
import numpy as np
#create data
x_data=np.random.rand(100).astype(np.float32)
y_data=x_data*0.1+0.3
###create tensorflow structure start###
Weights = tf.Variable(tf.random.uniform([1],-1.0,1.0))
biases = tf.Variable(tf.zeros([1]))
y=Weights*x_data+biases
loss = tf.reduce_mean(input_tensor=tf.square(y-y_data))
optimizer = tf.compat.v1.train.GradientDescentOptimizer(0.5)
###create tensorflow structure end###
train = optimizer.minimize(loss)
init = tf.compat.v1.initialize_all_variables()
sess = tf.compat.v1.Session()
sess.run(init)
for step in range(201):
    sess.run(train)
    if step % 20 == 0:
        print(step, sess.run(Weights), sess.run(biases))

代码对比可看出代码前后的变化

以上是关于tf_upgrade_v2.exe实验的主要内容,如果未能解决你的问题,请参考以下文章

201555332盛照宗—网络对抗实验1—逆向与bof基础

20155201 李卓雯 《网络对抗技术》实验一 逆向及Bof基础

使用 React 实验性中继片段:缺少属性 '"$fragmentRefs"'

[NTUSTISC pwn LAB 7]Return to libc实验(puts泄露libc中gadget片段定位)

angularJS使用ocLazyLoad实现js延迟加载

JSP 设计教师与学生不同登陆界面(带验证码)