У меня проблема с функцией freeze_graph:
ValueError: невозможно добавить операцию с именем Conv1 / W1 / Adam, так как это имя уже используется
В этой строке:
def export_model(input_node_names, output_node_name):
my_freeze_graph.freeze_graph('out/' + MODEL_NAME + '.pbtxt', None, False, 'out/' + MODEL_NAME + '.chkp', output_node_name, "save/restore_all", "save/Const:0", 'out/frozen_' + MODEL_NAME + '.pb', True, "")
Структура моей модели:
def get_model(input, dropout):
with tf.name_scope('Conv1'):
input_4D = tf.reshape(input, [-1, HEIGHT, WIDTH, 1])
w1 = tf.Variable(tf.truncated_normal([12, 8, 1, 44], stddev=0.01), name='W1')
b1 = tf.Variable(tf.zeros([44]), name='B1')
conv1 = tf.nn.conv2d(input_4D, w1, strides=[1, 1, 1, 1], padding='SAME')
act1 = tf.nn.relu(conv1 + b1)
drop1 = tf.nn.dropout(act1, dropout)
max_pool1 = tf.nn.max_pool(drop1, ksize=[1, 2, 2, 1], strides=[1, 2, 2, 1], padding='SAME')
tf.summary.histogram('weights', w1)
tf.summary.histogram('biases', b1)
tf.summary.histogram('activations', act1)
tf.summary.histogram('dropouts', drop1)
with tf.name_scope('Conv2'):
w2 = tf.Variable(tf.truncated_normal([6, 4, 44, 44], stddev=0.01), name='W2')
b2 = tf.Variable(tf.zeros([44]), name='B2')
conv2 = tf.nn.conv2d(max_pool1, w2, strides=[1, 1, 1, 1], padding='SAME')
act2 = tf.nn.relu(conv2 + b2)
drop2 = tf.nn.dropout(act2, dropout)
tf.summary.histogram('weights', w2)
tf.summary.histogram('biases', b2)
tf.summary.histogram('activations', act2)
tf.summary.histogram('dropouts', drop2)
conv_shape = drop2.get_shape()
count = int(conv_shape[1] * conv_shape[2] * conv_shape[3])
flat_output = tf.reshape(drop2, [-1, count])
with tf.name_scope('FC'):
w3 = tf.Variable(tf.truncated_normal([count, NUM_LABELS], stddev=0.01), name='W3')
b3 = tf.Variable(tf.zeros([NUM_LABELS]), name='B3')
fc = tf.add(tf.matmul(flat_output, w3), b3)
tf.summary.histogram('weights', w3)
tf.summary.histogram('biases', b3)
return fc
Что я сделал не так?
P.S. Версия Tensorflow 1.2.1, версия python 3.6.4