import tensorflow as tf import numpy as np import matplotlib.pyplot as plt #Import MNIST data from tensorflow.examples.tutorials.mnist import input_data mnist=input_data.read_data_sets("/niu/mnist_data/",one_hot=False) # Parameter learning_rate…
import tensorflow as tf import numpy as np import matplotlib.pyplot as plt #Import MNIST data from tensorflow.examples.tutorials.mnist import input_data mnist=input_data.read_data_sets("/niu/mnist_data/",one_hot=False) # Parameter learning_rate…
%SA:T1法利用Matlab编写主函数实现对定义域[-5,5]上的二元函数求最优解—Jason niu [x,y] = meshgrid(-5:0.1:5,-5:0.1:5); z = x.^2 + y.^2 - 10*cos(2*pi*x) - 10*cos(2*pi*y) + 20; figure mesh(x,y,z) hold on xlabel('x') ylabel('y') zlabel('z') title('SA:利用SA最优化,定义域[-5,5]上的二元函数z = x^2…
import tensorflow as tf from sklearn.datasets import load_digits #from sklearn.cross_validation import train_test_split from sklearn.model_selection import train_test_split from sklearn.preprocessing import LabelBinarizer # load data digits = load_di…
1. tf.layers.conv2d(input, filter, kernel_size, stride, padding) # 进行卷积操作 参数说明:input输入数据, filter特征图的个数,kernel_size卷积核的大小,stride步长,padding是否补零 2. tf.layers.conv2d_transpose(input, filter, kernel_size, stride, padding) # 进行反卷积操作 参数说明:input输入数据, filter特…
import tensorflow as tf # 22 scope (name_scope/variable_scope) from __future__ import print_function class TrainConfig: batch_size = 20 time_steps = 20 input_size = 10 output_size = 2 cell_size = 11 learning_rate = 0.01 class TestConfig(TrainConfig):…
# tensorflow中的两种定义scope(命名变量)的方式tf.get_variable和tf.Variable.Tensorflow当中有两种途径生成变量 variable import tensorflow as tf #T1法 tf.name_scope() with tf.name_scope("a_name_scope"): initializer = tf.constant_initializer(value=1) #定义常量 var1 = tf.get_variab…
import tensorflow as tf import numpy as np import matplotlib.pyplot as plt BATCH_START = 0 TIME_STEPS = 20 BATCH_SIZE = 50 INPUT_SIZE = 1 OUTPUT_SIZE = 1 CELL_SIZE = 10 LR = 0.006 BATCH_START_TEST = 0 def get_batch(): global BATCH_START, TIME_STEPS #…
import tensorflow as tf import numpy as np import matplotlib.pyplot as plt BATCH_START = 0 TIME_STEPS = 20 BATCH_SIZE = 50 INPUT_SIZE = 1 OUTPUT_SIZE = 1 CELL_SIZE = 10 LR = 0.006 BATCH_START_TEST = 0 def get_batch(): global BATCH_START, TIME_STEPS x…
import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data mnist = input_data.read_data_sets('MNIST_data', one_hot=True) lr=0.001 training_iters=100000 batch_size=128 n_inputs=28 n_steps=28 n_hidden_units=128 n_classes=10 x=tf…