TensorFlow练习18: 根据姓名判断性别

本帖训练一个可以根据姓名判断性别的CNN模型;我使用自己爬取的35万中文姓名进行训练。

使用同样的数据集还可以训练起名字模型,参看:

准备姓名数据集

我上网找了一下,并没有找到现成的中文姓名数据集,额,看来只能自己动手了。

我写了一个简单的Python脚本,爬取了上万中文姓名,格式整理如下:

如果你需要这个数据集,可以使用邮件或微信联系我。

训练模型

执行结果:

TensorFlow练习18: 根据姓名判断性别


服务器又该续费了,如果你要使用DigitalOcean VPS,欢迎使用网页底部的链接注册,你会免费获赠10刀。另外,感谢各位码友的支持。

如要转载,请保持本文完整,并注明作者@斗大的熊猫和本文原始地址: http://blog.topspeedsnail.com/archives/10833

相关文章

《TensorFlow练习18: 根据姓名判断性别》有6个想法

  1. tensorflow版本0.12.head运行报错如下:
    楼主有什么建议吗?

    File “train.py”, line 120, in
    train_neural_network()
    File “train.py”, line 99, in train_neural_network
    output = neural_network(len(vocabulary_list))
    File “train.py”, line 85, in neural_network
    h_pool = tf.concat(3, pooled_outputs)
    File “/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/array_ops.py”, line 1053, in concat
    dtype=dtypes.int32).get_shape(
    File “/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py”, line 651, in convert_to_tensor
    as_ref=False)
    File “/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py”, line 716, in internal_convert_to_tensor
    ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref)
    File “/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/constant_op.py”, line 176, in _constant_tensor_conversion_function
    return constant(v, dtype=dtype, name=name)
    File “/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/constant_op.py”, line 165, in constant tensor_util.make_tensor_proto(value, dtype=dtype, shape=shape, verify_shape=verify_shape))
    File “/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/tensor_util.py”, line 367, in make_tensor_proto
    _AssertCompatible(values, dtype)
    File “/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/tensor_util.py”, line 302, in _AssertCompatible
    (dtype.name, repr(mismatch), type(mismatch).__name__))
    TypeError: Expected int32, got list containing Tensors of type ‘_Message’ instead.

发表评论

电子邮件地址不会被公开。 必填项已用*标注