美文网首页
TensorFlow训练mnist模型

TensorFlow训练mnist模型

作者: 日常采坑君 | 来源:发表于2018-08-20 10:49 被阅读0次

    利用TensorFlow跑官网模型MNIST

    TensorFlow mnistModels


    单机跑通mnist模型

    1. Requirements
      a. TensorFlow1.4版本以上
      b. 从git上下载仓库https://github.com/tensorflow/models/tree/master/official
      c. Add the top-level /models folder to the Python path with the command:
      export PYTHONPATH="$PYTHONPATH:/path/to/models"
      d. 安装Python依赖库:
      pip install --user -r official/requirements.txt
      2.单机运行测试
      python mnist.py
      3.Exporting the model
      python mnist.py --export_dir /tmp/mnist_saved_model

    分布式跑mnist模型

    ps:10.87.219.7
    worker1:10.87.219.8
    worker2:10.87.219.9
    
    1. 下载mnist训练集
      http://yann.lecun.com/exdb/mnist/
    2. 下载TF经典入门实例手写字体识别MNIST基于分布式的实例
      Git地址:https://github.com/TracyMcgrady6/Distribute_MNIST
    3. Distribute_MNIST/distribute.py中,配置ps、worker的IP地址:
      flags.DEFINE_string('ps_hosts', '10.87.219.7:22221', 'Comma-separated list of hostname:port pairs') #参数服务器parameter server节点 flags.DEFINE_string('worker_hosts', '10.87.219.8:22221,10.87.219.:22221', 'Comma-separated list of hostname:port pairs')#两个worker节点
    4. 同步文件夹到2个worker机器
      将上述配置完成的两个文件夹的内容通过alluxio命令同步到两个worker中:
    image.png
    1. 尝试执行命令开始分布式训练:
      ps节点执行:
      python distributed.py --job_name=ps --task_index=0
      worker1节点执行:
      python distributed.py --job_name=worker --task_index=0
      worker2节点执行:
      python distributed.py --job_name=worker --task_index=1
      这里,参数服务器节点出现Started server with target: grpc://localhost:22221提示时,打开服务器,继续执行。在此过程中,两个worker出现如下的提示信息,即等待参数的传递:
      image.png

    相关文章

      网友评论

          本文标题:TensorFlow训练mnist模型

          本文链接:https://www.haomeiwen.com/subject/pwykiftx.html