转化tensorflow1.x版本构建的.pb文件的时候报错
收藏回复举报
转化tensorflow1.x版本构建的.pb文件的时候报错
t('forum.solved') 已解决
新人帖
发表于2023-07-14 16:20:36
0 查看

转化tensorflow1.x版本构建的模型为.om模型的时候报错

以下是报错代码

cke_1378.png

模型代码为

# 定义全连接层函数
def fcn_layer(inputs,               # 输入数据
              input_dim,            # 输入神经元数量
              output_dim,           # 输出神经元数量
              activation=None):     # 激活函数

    w = tf.Variable(tf.compat.v1.truncated_normal([input_dim, output_dim], stddev=0.1))
    b = tf.Variable(tf.zeros([output_dim]))

    xwb = tf.matmul(inputs, w) + b

    if activation is None:
        outputs = xwb
    else:
        outputs = activation(xwb)

    return outputs


# 保存模型
# 模型的存储粒度
save_step = 5

# 创建模型保存的文件的目录
ckpt_dir = "E:/vcspace/model/xunlian_dir_about_chang/"
if not os.path.exists(ckpt_dir):
    os.makedirs(ckpt_dir)


# 构建输入层
# 定义标签数据占位符
tf.compat.v1.disable_eager_execution()
x = tf.compat.v1.placeholder(tf.float32, [None, 400], name="X")
y = tf.compat.v1.placeholder(tf.float32, [None, 66], name="Y")


# 构建隐藏层
H1_NN = xxxx   # 第1隐藏层神经元数量
H2_NN = xxxx   # 第2隐藏层神经元数量
H3_NN = xxxx    # 第3隐藏层神经元数量

# 输入层 - 第1隐藏层参数和偏置项(构建第1隐藏层)
h1 = fcn_layer(inputs=x, input_dim=400, output_dim=H1_NN, activation=tf.nn.relu)

# 第1隐藏层 - 第2隐藏层参数和偏执项(构建第2隐藏层)
h2 = fcn_layer(inputs=h1, input_dim=H1_NN, output_dim=H2_NN, activation=tf.nn.relu)

# 第2隐藏层 - 第3隐藏层参数和偏置项(构建第3隐藏层)
h3 = fcn_layer(inputs=h2, input_dim=H2_NN, output_dim=H3_NN, activation=tf.nn.relu)

# 第3隐藏层 - 输出层参数和偏置项(构建输出层)
forward = fcn_layer(inputs=h3, input_dim=H3_NN, output_dim=66, activation=None)

pred = tf.nn.softmax(forward)

我要发帖子