共 40 篇文章 |
|
img = tf.decode_raw(features[''''''''image''''''''], tf.uint8)img = tf.reshape(img, [300, 300,3])#notice shape应该保持一致。TFRecordReader() _, serialized_example = reader.read(filename_queue) #返回文件名和文件 features = tf.parse_single_example(serialize... 阅22 转0 评0 公众公开 18-09-14 13:58 |
path = "/home/mj/cats_vs_dogs/data/expermient"filenames=os.listdir(path)writer = tf.python_io.for name in os.listdir(path): class_path = path + os.sep + name for img_name in os.listdir(class_path): img_path = class_path+os.sep+img_name img = Image.open(img_path) img = img.resize((500,500)) img_raw = img.toby... 阅60 转0 评0 公众公开 18-09-14 13:24 |
import cv2import osdef rebuild(dir): for root,dirs,files in os.walk(dir): for file in files: filepath=os.path.join(root,file) try: image=cv2.imread(filepath) dim=(227,227) resized=cv2.resize(image,dim) path="/home/mj/kaggle/retrain1/"+file cv2.imwrite(path,resized) except: print(filepath) os.remove(filepath) 阅830 转8 评0 公众公开 18-08-28 16:06 |
阅81 转0 评0 公众公开 18-08-15 16:31 |
x=tf.placeholder(tf.float32,[None,784])y=tf.placeholder(tf.float32,[None,10])Variable(tf.zeros(10))prediction=tf.nn.softmax(tf.matmul(x,w)+b)loss=tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits_v2(labels=y,logits=prediction))correct_prediction=tf.equal(tf.argmax(y,1),tf.argmax(prediction,1))accu=tf.reduce_mean(... 阅15 转0 评0 公众公开 18-08-14 16:22 |
x=tf.placeholder(tf.float32,[None,784])y=tf.placeholder(tf.float32,[None,10])Variable(tf.zeros(10))prediction=tf.nn.softmax(tf.matmul(x,w)+b)loss=tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits_v2(labels=y,logits=prediction))correct_prediction=tf.equal(tf.argmax(y,1),tf.argmax(prediction,1))accu=tf.reduce_mean(... 阅24 转1 评0 公众公开 18-08-14 16:14 |
<ipython-input-8-a4f3de4a35a8> in RNN(X, weights, biases) 38 inputs = tf.reshape(X,[-1,max_time,n_inputs]) 39 #定义LSTM基本CELL---> 40 lstm_cell = tf.contrib.rnn.core_rnn_cell.BasicLSTMCell(lstm_size) 41 #lstm_cell = rnn.BasicLSTMCell(lstm_size) 42 # final_state[0]是cell stateAttributeError: module ''... 阅310 转0 评0 公众公开 18-08-01 14:48 |
import tensorflow as tffrom tensorflow.contrib import rnnfrom tensorflow.examples.tutorials.mnist import input_data#载入数据mnist = input_data.read_data_sets("/home/mj/MINIST_data", one_hot=True)#输入图片是28*28n_inputs=28#max_time=28lstm_size=100n_classes=10batch_size=50n_batch=mnist.train.num_examplesx=tf.... 阅26 转0 评0 公众公开 18-08-01 14:46 |
模型与训练的模型要相同,包括nameimport tensorflow as tfimport numpy as np##saive to filew=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='''... 阅10 转0 评0 公众公开 18-07-28 16:15 |