昇腾故障案例详情页

数据预处理中存在tf.Variable需要手工修改

更新时间: 2022/08/16

暂无评分

问题信息

问题来源产品大类产品子类关键字
官方模型训练TensorFlow数据预处理、tf.Variable

问题现象描述

变量和变量初始化图不在同一设备执行,导致训练异常。

原因分析

数据预处理中存在tf.Variable时,tf.Variable在Host侧执行,而变量初始化图默认在Device侧执行。变量和变量初始化图不在同一设备执行,会导致训练异常,需要手工迁移。

    batch_size = tf.Variable(
         tf.placeholder(tf.int64, [], 'batch_size'),
         trainable= False, collections=[]
    )
    train_dataset = train_dataset.batch(batch_size, drop_remainder=True)

解决措施

将tf.Variable修改成常量,即可解决问题:

    batch_size = 64
    train_dataset = train_dataset.batch(batch_size, drop_remainder=True)

本页内容

该页面对您有帮助吗?
我要评分