基于tf2.0的python中文手写识别项目ocrcn_tf2为什么调不通,我们带您破案

为了把手写文本(如历史值班手册等)转化为电子文本,最近尝试在github上查找相关开源项目。功夫不负有心人,找到了基于TensorFlow2.0的中文手写字识别模型,其采用CASIA-HWDB数据集,设计了神经网络达到了相当不错的识别率。
项目地址如下:
https://github.com/jjcheer/ocrcn_tf2
按照操作流程,下载数据,转换格式,生成训练样本。
结果报错如下:
tensorflow.python.framework.errors_impl.InvalidArgumentError: { {function_node __inference_Dataset_map_parse_example_25}} Input to reshape is a tensor with 4446 values, but the requested shape has 4096
看起来是进入模型的数据格式有问题啊,看了下./train_simple.py里面如下代码报错:

def train():
    all_characters = load_characters()
    num_classes = len(all_characters)
    logging.info('all characters: {}'.format(num_classes))
    train_dataset = load_ds()
    train_dataset = train_dataset.shuffle(100).map(preprocess).batch(32).repeat()

应该是整个load_ds的问题。
观察./dataset/casia_hwdb.py中的parse_example函数存在原版和V2版本,而在load_ds上调用的是parse_example,而load_val_ds中调用的则是parse_example_v2。

def parse_example(record):
    features = tf.io.parse_single_example(record,
                                          features={
   
                                              
  • 6
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 14
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 14
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值