import numpy as np import tensorflow as tf import matplotlib.pyplot as plt threshold = 1.0e-2 x1_data = np.random.randn(100).astype(np.float32) x2_data = np.random.randn(100).astype(np.float32) y_data = x1_data * 2 + x2_data * 3 + 1.5 weight1 = tf.Va…
import tensorflow as tf import tensorflow.examples.tutorials.mnist.input_data as input_data mnist = input_data.read_data_sets("D:\\F\\TensorFlow_deep_learn\\MNIST\\", one_hot=True) x_data = tf.placeholder("float32", [None, 784]) weight…
# coding: utf-8 import time import numpy as np import tensorflow as tf import _pickle as pickle import matplotlib.pyplot as plt def unpickle(filename): import pickle with open(filename, 'rb') as fo: data = pickle.load(fo, encoding='latin1') return da…
import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data import time # 声明输入图片数据,类别 x = tf.placeholder('float', [None, 784]) y_ = tf.placeholder('float', [None, 10]) # 输入图片数据转化 x_image = tf.reshape(x, [-1, 28, 28, 1]) #第一层卷积层…
import struct import numpy as np import matplotlib.pyplot as plt dateMat = np.ones((7,7)) kernel = np.array([[2,1,1],[3,0,1],[1,1,0]]) def convolve(dateMat,kernel): m,n = dateMat.shape km,kn = kernel.shape newMat = np.ones(((m - km + 1),(n - kn + 1))…
import numpy as np import matplotlib.pyplot as plt x_data = np.random.randn(10) print(x_data) y_data = x_data * 0.3 + 0.15 print(y_data) plt.plot(x_data,y_data) plt.scatter(x_data,y_data,c="r") plt.show() import numpy as np import tensorflow as…
import tensorflow as tf q = tf.FIFOQueue(,"float32") counter = tf.Variable(0.0) add_op = tf.assign_add(counter, tf.constant(1.0)) enqueueData_op = q.enqueue(counter) sess = tf.Session() qr = tf.train.QueueRunner(q, enqueue_ops=[add_op, enqueueDa…
import numpy as np from matplotlib import pyplot as plt A = np.array([[5],[4]]) C = np.array([[4],[6]]) B = A.T.dot(C) AA = np.linalg.inv(A.T.dot(A)) l=AA.dot(B) P=A.dot(l) x=np.linspace(-2,2,10) x.shape=(1,10) xx=A.dot(x) fig = plt.figure() ax= fig.…
import tensorflow as tf input1 = tf.constant(1) print(input1) input2 = tf.Variable(2,tf.int32) print(input2) input2 = input1 sess = tf.Session() print(sess.run(input2)) import tensorflow as tf input1 = tf.placeholder(tf.int32) input2 = tf.placeholder…
import numpy as np import tensorflow as tf inputX = np.random.rand(100) inputY = np.multiply(3,inputX) + 1 x = tf.placeholder("float32") y_ = tf.placeholder("float32") weight = tf.Variable(0.25) bias = tf.Variable(0.25) y = tf.multiply…