如何用vgg模型来训练自己本人的数据库tensorflow

如何用vgg模型来训练自己本人的数据库tensorflow,第1张

使用 TensorFlow, 你必须明白 TensorFlow:

使用图 (graph) 来表示计算任务.

在被称之为 会话 (Session) 的上下文 (context) 中执行图.

使用 tensor 表示数据.

通过 变量 (Variable) 维护状态.

使用 feed 和 fetch 可以为任意的 *** 作(arbitrary operation) 赋值或者从其中获取数据.

综述

TensorFlow 是一个编程系统, 使用图来表示计算任务. 图中的节点被称之为 op

(operation 的缩写). 一个 op 获得 0 个或多个 Tensor, 执行计算,

产生 0 个或多个 Tensor. 每个 Tensor 是一个类型化的多维数组.

例如, 你可以将一小组图像集表示为一个四维浮点数数组,

这四个维度分别是 [batch, height, width, channels].

一个 TensorFlow 图描述了计算的过程. 为了进行计算, 图必须在 会话 里被启动.

会话 将图的 op 分发到诸如 CPU 或 GPU 之类的 设备 上, 同时提供执行 op 的方法.

这些方法执行后, 将产生的 tensor 返回. 在 Python 语言中, 返回的 tensor 是

numpy ndarray 对象在 C 和 C++ 语言中, 返回的 tensor 是

tensorflow::Tensor 实例.

# -*- coding:utf-8 -*-import tensorflow as tf filename_queue = tf.train.string_input_producer(["file01.csv", "file02.csv"])reader = tf.TextLineReader()key, value = reader.read(filename_queue) # Default values, in case of empty columns. Also specifies the type of the# decoded result.record_defaults = [[1], [1], [1]]col1, col2, col3 = tf.decode_csv(value, record_defaults = record_defaults)features = tf.stack([col1, col2]) init_op = tf.global_variables_initializer()local_init_op = tf.local_variables_initializer() # local variables like epoch_num, batch_size 可以不初始化localwith tf.Session() as sess:sess.run(init_op)sess.run(local_init_op) # Start populating the filename queue.coord = tf.train.Coordinator()threads = tf.train.start_queue_runners(coord=coord) for i in range(5):# Retrieve a single instance:example, label = sess.run([features, col3])print(example)print(label) coord.request_stop()coord.join(threads)


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/sjk/9402982.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-28
下一篇2023-04-28

发表评论

登录后才能评论

评论列表(0条)

    保存