吴裕雄--天生自然 pythonTensorFlow自然语言处理:Seq2Seq模型--测试
摘要:import sys import codecs import tensorflow as tf # 1.参数设置。 # 读取checkpoint的路径。9000表示是训练程序在第9000步保存的checkpoint。 CHECKPOINT_PATH = "F:\\temp\\seq2seq_ckpt-9000" # 模型参数。必须与训练时的模型参数保持一致。 HIDDEN_SIZE = 1024
阅读全文
吴裕雄--天生自然 pythonTensorFlow图形数据处理:数据集高层操作
摘要:import tempfile import tensorflow as tf # 1. 列举输入文件。 # 输入数据生成的训练和测试数据。 train_files = tf.train.match_filenames_once("F:\\output.tfrecords") test_files = tf.train.match_filenames_once("F:\\output_test...
阅读全文
吴裕雄--天生自然 pythonTensorFlow图形数据处理:数据集基本使用方法
摘要:import tempfile import tensorflow as tf # 1. 从数组创建数据集。 input_data = [1, 2, 3, 5, 8] dataset = tf.data.Dataset.from_tensor_slices(input_data) # 定义迭代器。 iterator = dataset.make_one_shot_iterator() # get_
阅读全文
吴裕雄--天生自然 pythonTensorFlow图形数据处理:输入数据处理框架
摘要:import tensorflow as tf # 1. 创建文件列表,通过文件列表创建输入文件队列 files = tf.train.match_filenames_once("F:\\output.tfrecords") filename_queue = tf.train.string_input_producer(files, shuffle=False) #解析TFRecord文件里的数据
阅读全文
吴裕雄--天生自然 pythonTensorFlow图形数据处理:输入文件队列
摘要:import tensorflow as tf # 1. 生成文件存储样例数据。 def _int64_feature(value): return tf.train.Feature(int64_list=tf.train.Int64List(value=[value])) num_shards = 2 instances_per_shard = 2 for i in range(num_shar
阅读全文
吴裕雄--天生自然 pythonTensorFlow图形数据处理:多线程队列操作
摘要:import tensorflow as tf #1. 定义队列及其操作。 queue = tf.FIFOQueue(100,"float") enqueue_op = queue.enqueue([tf.random_normal([1])]) qr = tf.train.QueueRunner(queue, [enqueue_op] * 5) tf.train.add_queue_runn...
阅读全文
吴裕雄--天生自然 pythonTensorFlow图形数据处理:队列操作
摘要:import tensorflow as tf #1. 创建队列,并操作里面的元素。 q = tf.FIFOQueue(2, "int32") init = q.enqueue_many(([0, 10],)) x = q.dequeue() y = x + 1 q_inc = q.enqueue([y]) with tf.Session() as sess: init.run() ...
阅读全文
吴裕雄--天生自然 pythonTensorFlow图形数据处理:图像预处理完整样例
摘要:import numpy as np import tensorflow as tf import matplotlib.pyplot as plt #随机调整图片的色彩,定义两种顺序。 def distort_color(image, color_ordering=0): if color_ordering == 0: image = tf.image.random_brightness(ima
阅读全文
吴裕雄--天生自然 pythonTensorFlow图形数据处理:TensorFlow图像处理函数
摘要:import numpy as np import tensorflow as tf import matplotlib.pyplot as plt #读取图片 image_raw_data = tf.gfile.FastGFile("F:\\TensorFlowGoogle\\201806-github\\datasets\\cat.jpg",'rb').read() with tf.Sessi
阅读全文
吴裕雄--天生自然 pythonTensorFlow图形数据处理:读取MNIST手写图片数据写入的TFRecord文件
摘要:import numpy as np import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data # 读取文件。 filename_queue = tf.train.string_input_producer(["F:\\output.tfrecords"]) reader = tf.T...
阅读全文
吴裕雄--天生自然 pythonTensorFlow图形数据处理:将MNIST手写图片数据写入TFRecord文件
摘要:import numpy as np import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data # 定义函数转化变量类型。 def _int64_feature(value): return tf.train.Feature(int64_list=tf.train.Int64List(val
阅读全文
吴裕雄--天生自然python TensorFlow图片数据处理:解决TensorFlow2.0 module ‘tensorflow’ has no attribute ‘python_io’
摘要:tf.python_io出错 TensorFlow 2.0 中使用 Python_io 暂时使用如下指令: tf.compat.v1.python_io.TFRecordWriter(filename)
阅读全文
吴裕雄--天生自然python TensorFlow图片数据处理:No module named 'tensorflow.examples.tutorials'解决办法
摘要:1.在自己编译器运行的python环境的...\Python3\Lib\site-packages,该目录下有文件夹tensorflow, tensorflow_core, ensorflow_estimator 2.进入tensorflow_core\examples文件夹,如果文件夹下只有sav
阅读全文