1. 命名空间的问题。对图中的 < with tf.variable_scope('controlNET') as scope: > 进行注释。
打印张量所在的名称空间代码如下
import os
from tensorflow.python import pywrap_tensorflow
# current_path = os.getcwd()
# model_dir = os.path.join(current_path, 'model.ckpt')
model_dir = '/home/binghong/documents/PycharmProjects_backup/Immitation_Learning/carlaILTrainer-master/test/'
checkpoint_path = os.path.join(model_dir,'model.ckpt') # 保存的ckpt文件名,不一定是这个
# Read data from checkpoint file
reader = pywrap_tensorflow.NewCheckpointReader(checkpoint_path)
var_to_shape_map = reader.get_variable_to_shape_map()
# Print tensor name and values
for key in var_to_shape_map:
print("tensor_name: ", key)
2. 注意data.close()的位置
def genData(fileNames = datasetFilesTrain, batchSize = 200):
#fileNames = datasetFilesTrain
#branchNum = 3 # Control signal, int ( 2 Follow lane, 3 Left, 4 Right, 5 Straight)
#batchSize = 200
batchX = np.zeros((batchSize, 88, 200, 3))
batchY = np.zeros((batchSize, 28))
idx = 0
while True: # to make sure we never reach the end
counter = 0
while counter<=batchSize-1:
idx = np.random.randint(len(fileNames)-1)
try:
data = h5py.File(fileNames[idx], 'r')
except:
print(idx, fileNames[idx])
dataIdx = np.random.randint(200-1)
batchX[counter] = data['rgb'][dataIdx]
batchY[counter] = data['targets'][dataIdx]
counter += 1
#data.close()
yield (batchX, batchY)
data.close()
def genBranch(fileNames = datasetFilesTrain, branchNum = 3, batchSize = 200):
#fileNames = datasetFilesTrain
#branchNum = 3 # Control signal, int ( 2 Follow lane, 3 Left, 4 Right, 5 Straight)
#batchSize = 200
batchX = np.zeros((batchSize, 88, 200, 3))
batchY = np.zeros((batchSize, 28))
idx = 0
while True: # to make sure we never reach the end
counter = 0
while counter<=batchSize-1:
idx = np.random.randint(len(fileNames)-1)
try:
data = h5py.File(fileNames[idx], 'r')
except:
print(idx, fileNames[idx])
dataIdx = np.random.randint(200-1)
if data['targets'][dataIdx][24] == branchNum:
batchX[counter] = data['rgb'][dataIdx]
batchY[counter] = data['targets'][dataIdx]
counter += 1
#data.close()
yield (batchX, batchY)
data.close()



