小编Fra*_*Fan的帖子

Tensorflow:.ckpt文件和.ckpt.meta和.ckpt.index以及.pb文件之间的关系是什么

我曾经saver=tf.train.Saver()保存过我训练过的模型,我得到了三种名为的文件:

  • .ckpt.meta
  • .ckpt.index
  • .ckpt.data

并且文件名为:

  • 检查站

.ckpt文件的连接是什么?

我看到有人用.ckpt文件保存模型,我不知道怎么做.如何将模型保存为.pb文件?

python tensorflow

23
推荐指数
1
解决办法
2万
查看次数

提取参数<tf.Tensor'batch:0'shape =(128,56,56,3)dtype = float32>不能解释为张量。

我写了一个测试代码,当我运行它时,它说Fetch参数不能解释为张量。我真的不知道发生了什么。有人可以告诉我如何解决它吗?非常感谢你。这里是代码

# coding=utf-8
from  color_1 import read_and_decode, get_batch, get_test_batch
import color_inference
import cv2
import os
import time
import numpy as np
import tensorflow as tf
import color_train
import math

EVAL_INTERVAL_SECS=10
batch_size=128
num_examples = 10000
crop_size=56
def test(test_x, test_y):
    with tf.Graph().as_default() as g:
        image_holder = tf.placeholder(tf.float32, [batch_size, 56, 56, 3], name='x-input')
        label_holder = tf.placeholder(tf.int32, [batch_size], name='y-input')

        y=color_inference.inference(image_holder)

        num_iter = int(math.ceil(num_examples / batch_size))
        true_count = 0
        total_sample_count = num_iter * batch_size
        saver=tf.train.Saver()
        top_k_op = tf.nn.in_top_k(y, label_holder, 1)
        while True:
            with tf.Session() as …
Run Code Online (Sandbox Code Playgroud)

python deep-learning tensorflow

5
推荐指数
1
解决办法
6625
查看次数

我该如何解决这个问题:“RuntimeError: Attempted to use a closed Session.”

当我运行以下 Tensorflow 代码时,我收到一个 RuntimeError,显示“尝试使用关闭的会话”。有人能告诉我如何解决这个错误吗?这是代码:

# coding=utf-8
# (...imports omitted...)

# (...some constant declarations and helper functions omitted:
#  max_steps, batch_size, log_dir, variable_with_weight_loss, variable_summaries,
#  layer1, full_layer1, full_layer2, full_layer3, loss
#  ...)

def run():
    image, label = read_and_decode('train.tfrecords')
    batch_image, batch_label = get_batch(image, label, batch_size=128, crop_size=56) 

    test_image, test_label = read_and_decode('val.tfrecords')
    test_images, test_labels = get_test_batch(test_image, test_label, batch_size=128, crop_size=56)  # batch ????

    def feed_dict(train):
        if train:
            x=image_batch
            y=label_batch
        else:
            x=img_batch
            y=lab_batch
        return {image_holder:x,label_holder:y}

    saver=tf.train.Saver()
    num_examples = 10000
    num_iter = int(math.ceil(num_examples / batch_size))
    true_count = …
Run Code Online (Sandbox Code Playgroud)

tensorflow tensorboard

4
推荐指数
2
解决办法
2万
查看次数

Tensorflow:无法创建会话

我运行代码时出错,错误是:

tensorflow.python.framework.errors_impl.InternalError:无法创建会话.

这是我的代码:

# -*- coding: utf-8 -*-
import ...
import ...

checkpoint='/home/vrview/tensorflow/example/char/data/model/'
MODEL_SAVE_PATH = "/home/vrview/tensorflow/example/char/data/model/"

def getAllImages(folder):
    assert os.path.exists(folder)
    assert os.path.isdir(folder)
    imageList = os.listdir(folder)
    imageList = [os.path.join(folder,item) for item in imageList ]
    num=len(imageList)
    return imageList,num

def get_labei():
    img_dir, num = getAllImages(r"/home/vrview/tensorflow/example/char/data/model/file/")
    for i in range(num):
        image = Image.open(img_dir[i])
        image = image.resize([56, 56])
        image = np.array(image)
        image_array = image

        with tf.Graph().as_default():
            image = tf.cast(image_array, tf.float32)
            image_1 = tf.image.per_image_standardization(image)
            image_2 = tf.reshape(image_1, [1, 56, 56, 3])

            logit = color_inference.inference(image_2)
            y = …
Run Code Online (Sandbox Code Playgroud)

python tensorflow

4
推荐指数
3
解决办法
2万
查看次数

标签 统计

tensorflow ×4

python ×3

deep-learning ×1

tensorboard ×1