Kaynağa Gözat

add LeNet5 cnn structure, conv, polling, dropout. cnn must be trained in a better GPU

youchen 5 yıl önce
ebeveyn
işleme
1f26f95c7c
64 değiştirilmiş dosya ile 966 ekleme ve 34 silme
  1. 513 0
      .idea/workspace.xml
  2. 30 0
      LeNet5/accuracy_score_cnn.txt
  3. 30 0
      LeNet5/accuracy_score_fc.txt
  4. BIN
      LeNet5/images/mnist_result_evaluation.jpg
  5. 126 0
      LeNet5/mnist_eval.py
  6. 82 0
      LeNet5/mnist_inference.py
  7. 139 0
      LeNet5/mnist_train.py
  8. 6 0
      LeNet5/model/checkpoint
  9. BIN
      LeNet5/model/model.ckpt-17501.data-00000-of-00001
  10. BIN
      LeNet5/model/model.ckpt-17501.index
  11. BIN
      LeNet5/model/model.ckpt-17501.meta
  12. BIN
      LeNet5/model/model.ckpt-20001.data-00000-of-00001
  13. BIN
      LeNet5/model/model.ckpt-20001.index
  14. BIN
      LeNet5/model/model.ckpt-20001.meta
  15. BIN
      LeNet5/model/model.ckpt-22501.data-00000-of-00001
  16. BIN
      LeNet5/model/model.ckpt-22501.index
  17. BIN
      LeNet5/model/model.ckpt-22501.meta
  18. BIN
      LeNet5/model/model.ckpt-25001.data-00000-of-00001
  19. BIN
      LeNet5/model/model.ckpt-25001.index
  20. BIN
      LeNet5/model/model.ckpt-25001.meta
  21. BIN
      LeNet5/model/model.ckpt-2501.data-00000-of-00001
  22. BIN
      LeNet5/model/model.ckpt-2501.index
  23. BIN
      LeNet5/model/model.ckpt-2501.meta
  24. BIN
      LeNet5/model/model.ckpt-26001.data-00000-of-00001
  25. BIN
      LeNet5/model/model.ckpt-26001.index
  26. BIN
      LeNet5/model/model.ckpt-26001.meta
  27. BIN
      LeNet5/model/model.ckpt-27001.data-00000-of-00001
  28. BIN
      LeNet5/model/model.ckpt-27001.index
  29. BIN
      LeNet5/model/model.ckpt-27001.meta
  30. BIN
      LeNet5/model/model.ckpt-27501.data-00000-of-00001
  31. BIN
      LeNet5/model/model.ckpt-27501.index
  32. BIN
      LeNet5/model/model.ckpt-27501.meta
  33. BIN
      LeNet5/model/model.ckpt-28001.data-00000-of-00001
  34. BIN
      LeNet5/model/model.ckpt-28001.index
  35. BIN
      LeNet5/model/model.ckpt-28001.meta
  36. BIN
      LeNet5/model/model.ckpt-29001.data-00000-of-00001
  37. BIN
      LeNet5/model/model.ckpt-29001.index
  38. BIN
      LeNet5/model/model.ckpt-29001.meta
  39. BIN
      LeNet5/model/model.ckpt-7501.data-00000-of-00001
  40. BIN
      LeNet5/model/model.ckpt-7501.index
  41. BIN
      LeNet5/model/model.ckpt-7501.meta
  42. BIN
      mnist_number_recognition/images/mnist_accuracy_evaluation.png
  43. BIN
      mnist_number_recognition/images/with EMA.png
  44. BIN
      mnist_number_recognition/images/without EMA.png
  45. 18 13
      mnist_number_recognition/mnist_optimization.py
  46. 11 11
      mnist_number_recognition/model.ckpt.meda.json
  47. BIN
      mnist_restructured/images/mnist_result_evaluation.jpg
  48. 7 6
      mnist_restructured/mnist_eval.py
  49. 4 4
      mnist_restructured/mnist_train.py
  50. BIN
      mnist_restructured/model/model.ckpt-17501.data-00000-of-00001
  51. BIN
      mnist_restructured/model/model.ckpt-17501.index
  52. BIN
      mnist_restructured/model/model.ckpt-17501.meta
  53. BIN
      mnist_restructured/model/model.ckpt-20001.data-00000-of-00001
  54. BIN
      mnist_restructured/model/model.ckpt-20001.index
  55. BIN
      mnist_restructured/model/model.ckpt-20001.meta
  56. BIN
      mnist_restructured/model/model.ckpt-22501.data-00000-of-00001
  57. BIN
      mnist_restructured/model/model.ckpt-22501.index
  58. BIN
      mnist_restructured/model/model.ckpt-22501.meta
  59. BIN
      mnist_restructured/model/model.ckpt-25001.data-00000-of-00001
  60. BIN
      mnist_restructured/model/model.ckpt-25001.index
  61. BIN
      mnist_restructured/model/model.ckpt-25001.meta
  62. BIN
      mnist_restructured/model/model.ckpt-27501.data-00000-of-00001
  63. BIN
      mnist_restructured/model/model.ckpt-27501.index
  64. BIN
      mnist_restructured/model/model.ckpt-27501.meta

+ 513 - 0
.idea/workspace.xml

@@ -0,0 +1,513 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="ChangeListManager">
+    <list default="true" id="e9b46fa1-325b-4259-9fd8-0645dfce4e13" name="Default" comment="">
+      <change beforePath="$PROJECT_DIR$/mnist_number_recognition/images/mnist_accuracy_evaluation.png" beforeDir="false" afterPath="$PROJECT_DIR$/mnist_number_recognition/images/mnist_accuracy_evaluation.png" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/mnist_number_recognition/mnist_optimization.py" beforeDir="false" afterPath="$PROJECT_DIR$/mnist_number_recognition/mnist_optimization.py" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/mnist_number_recognition/model.ckpt.meda.json" beforeDir="false" afterPath="$PROJECT_DIR$/mnist_number_recognition/model.ckpt.meda.json" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/mnist_restructured/images/mnist_result_evaluation.jpg" beforeDir="false" afterPath="$PROJECT_DIR$/mnist_restructured/images/mnist_result_evaluation.jpg" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/mnist_restructured/mnist_eval.py" beforeDir="false" afterPath="$PROJECT_DIR$/mnist_restructured/mnist_eval.py" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/mnist_restructured/mnist_train.py" beforeDir="false" afterPath="$PROJECT_DIR$/mnist_restructured/mnist_train.py" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/mnist_restructured/model/model.ckpt-17501.data-00000-of-00001" beforeDir="false" afterPath="$PROJECT_DIR$/mnist_restructured/model/model.ckpt-17501.data-00000-of-00001" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/mnist_restructured/model/model.ckpt-17501.index" beforeDir="false" afterPath="$PROJECT_DIR$/mnist_restructured/model/model.ckpt-17501.index" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/mnist_restructured/model/model.ckpt-17501.meta" beforeDir="false" afterPath="$PROJECT_DIR$/mnist_restructured/model/model.ckpt-17501.meta" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/mnist_restructured/model/model.ckpt-20001.data-00000-of-00001" beforeDir="false" afterPath="$PROJECT_DIR$/mnist_restructured/model/model.ckpt-20001.data-00000-of-00001" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/mnist_restructured/model/model.ckpt-20001.index" beforeDir="false" afterPath="$PROJECT_DIR$/mnist_restructured/model/model.ckpt-20001.index" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/mnist_restructured/model/model.ckpt-20001.meta" beforeDir="false" afterPath="$PROJECT_DIR$/mnist_restructured/model/model.ckpt-20001.meta" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/mnist_restructured/model/model.ckpt-22501.data-00000-of-00001" beforeDir="false" afterPath="$PROJECT_DIR$/mnist_restructured/model/model.ckpt-22501.data-00000-of-00001" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/mnist_restructured/model/model.ckpt-22501.index" beforeDir="false" afterPath="$PROJECT_DIR$/mnist_restructured/model/model.ckpt-22501.index" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/mnist_restructured/model/model.ckpt-22501.meta" beforeDir="false" afterPath="$PROJECT_DIR$/mnist_restructured/model/model.ckpt-22501.meta" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/mnist_restructured/model/model.ckpt-25001.data-00000-of-00001" beforeDir="false" afterPath="$PROJECT_DIR$/mnist_restructured/model/model.ckpt-25001.data-00000-of-00001" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/mnist_restructured/model/model.ckpt-25001.index" beforeDir="false" afterPath="$PROJECT_DIR$/mnist_restructured/model/model.ckpt-25001.index" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/mnist_restructured/model/model.ckpt-25001.meta" beforeDir="false" afterPath="$PROJECT_DIR$/mnist_restructured/model/model.ckpt-25001.meta" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/mnist_restructured/model/model.ckpt-27501.data-00000-of-00001" beforeDir="false" afterPath="$PROJECT_DIR$/mnist_restructured/model/model.ckpt-27501.data-00000-of-00001" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/mnist_restructured/model/model.ckpt-27501.index" beforeDir="false" afterPath="$PROJECT_DIR$/mnist_restructured/model/model.ckpt-27501.index" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/mnist_restructured/model/model.ckpt-27501.meta" beforeDir="false" afterPath="$PROJECT_DIR$/mnist_restructured/model/model.ckpt-27501.meta" afterDir="false" />
+    </list>
+    <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
+    <option name="TRACKING_ENABLED" value="true" />
+    <option name="SHOW_DIALOG" value="false" />
+    <option name="HIGHLIGHT_CONFLICTS" value="true" />
+    <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
+    <option name="LAST_RESOLUTION" value="IGNORE" />
+  </component>
+  <component name="FavoritesManager">
+    <favorites_list name="TF" />
+  </component>
+  <component name="FileEditorManager">
+    <leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
+      <file leaf-file-name="mnist_inference.py" pinned="false" current-in-tab="false">
+        <entry file="file://$PROJECT_DIR$/mnist_restructured/mnist_inference.py">
+          <provider selected="true" editor-type-id="text-editor">
+            <state relative-caret-position="480">
+              <caret line="24" selection-start-line="24" selection-end-line="24" />
+            </state>
+          </provider>
+        </entry>
+      </file>
+      <file leaf-file-name="mnist_train.py" pinned="false" current-in-tab="false">
+        <entry file="file://$PROJECT_DIR$/mnist_restructured/mnist_train.py">
+          <provider selected="true" editor-type-id="text-editor">
+            <state relative-caret-position="740">
+              <caret line="42" column="45" selection-start-line="42" selection-start-column="45" selection-end-line="42" selection-end-column="45" />
+              <folding>
+                <element signature="e#23#32#0" expanded="true" />
+              </folding>
+            </state>
+          </provider>
+        </entry>
+      </file>
+      <file leaf-file-name="mnist_eval.py" pinned="false" current-in-tab="true">
+        <entry file="file://$PROJECT_DIR$/mnist_restructured/mnist_eval.py">
+          <provider selected="true" editor-type-id="text-editor">
+            <state relative-caret-position="300">
+              <caret line="15" selection-start-line="15" selection-end-line="15" />
+              <folding>
+                <element signature="e#23#34#0" expanded="true" />
+              </folding>
+            </state>
+          </provider>
+        </entry>
+      </file>
+    </leaf>
+  </component>
+  <component name="FileTemplateManagerImpl">
+    <option name="RECENT_TEMPLATES">
+      <list>
+        <option value="Python Script" />
+      </list>
+    </option>
+  </component>
+  <component name="FindInProjectRecents">
+    <findStrings>
+      <find>format</find>
+    </findStrings>
+  </component>
+  <component name="Git.Settings">
+    <option name="PREVIOUS_COMMIT_AUTHORS">
+      <list>
+        <option value="youchen &lt;18202736439@163.com&gt;" />
+        <option value="carbo-T &lt;18202736439@163.com&gt;" />
+        <option value="youchen" />
+        <option value="carbo-T" />
+      </list>
+    </option>
+    <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
+    <option name="PUSH_TAGS">
+      <GitPushTagMode />
+    </option>
+  </component>
+  <component name="IdeDocumentHistory">
+    <option name="CHANGED_PATHS">
+      <list>
+        <option value="$PROJECT_DIR$/TF_Init/Ubuntu_GPUBased_TF_Installation_note" />
+        <option value="$PROJECT_DIR$/TF_Init/Ubuntu_GPUBased_TF_Installation_sysInfo" />
+        <option value="$PROJECT_DIR$/TF_Init/Ubuntu_GPUBased_TF_Installation_notes" />
+        <option value="$PROJECT_DIR$/graph_test.py" />
+        <option value="$PROJECT_DIR$/tests/tensor_session.py" />
+        <option value="$PROJECT_DIR$/tests/NNSample01.py" />
+        <option value="$PROJECT_DIR$/tests/ExponentialMovingAvg.py" />
+        <option value="$PROJECT_DIR$/mnist_number_recognition/mnist_dataset.py" />
+        <option value="$PROJECT_DIR$/tests/forward_propagation.py" />
+        <option value="$PROJECT_DIR$/tests/model.ckpt.meda.json" />
+        <option value="$PROJECT_DIR$/mnist_restructured/mnist_inference.py" />
+        <option value="$PROJECT_DIR$/mnist_number_recognition/mnist_optimization.py" />
+        <option value="$PROJECT_DIR$/mnist_restructured/mnist_train.py" />
+        <option value="$PROJECT_DIR$/mnist_restructured/mnist_eval.py" />
+      </list>
+    </option>
+  </component>
+  <component name="ProjectFrameBounds">
+    <option name="x" value="227" />
+    <option name="y" value="32" />
+    <option name="width" value="1414" />
+    <option name="height" value="1004" />
+  </component>
+  <component name="ProjectLevelVcsManager">
+    <ConfirmationsSetting value="2" id="Add" />
+  </component>
+  <component name="ProjectView">
+    <navigator proportions="" version="1">
+      <foldersAlwaysOnTop value="true" />
+    </navigator>
+    <panes>
+      <pane id="ProjectPane">
+        <subPane>
+          <expand>
+            <path>
+              <item name="TF" type="b2602c69:ProjectViewProjectNode" />
+              <item name="TF" type="462c0819:PsiDirectoryNode" />
+            </path>
+          </expand>
+          <select />
+        </subPane>
+      </pane>
+      <pane id="Scope" />
+    </panes>
+  </component>
+  <component name="PropertiesComponent">
+    <property name="ChangesTree.GroupingKeys" value="directory" />
+    <property name="last_opened_file_path" value="$PROJECT_DIR$/../ProxySpider" />
+    <property name="settings.editor.selected.configurable" value="project.propVCSSupport.Mappings" />
+  </component>
+  <component name="PyConsoleOptionsProvider">
+    <option name="myPythonConsoleState">
+      <console-settings module-name="TF" is-module-sdk="true">
+        <envs>
+          <env key="LD_LIBRARY_PATH" value="//usr/local/cuda/lib64" />
+        </envs>
+        <option name="myUseModuleSdk" value="true" />
+        <option name="myModuleName" value="TF" />
+        <option name="myEnvs">
+          <map>
+            <entry key="LD_LIBRARY_PATH" value="//usr/local/cuda/lib64" />
+          </map>
+        </option>
+      </console-settings>
+    </option>
+  </component>
+  <component name="RecentsManager">
+    <key name="CopyFile.RECENT_KEYS">
+      <recent name="$PROJECT_DIR$/mnist_restructured" />
+    </key>
+    <key name="MoveFile.RECENT_KEYS">
+      <recent name="$PROJECT_DIR$" />
+      <recent name="$PROJECT_DIR$/tests" />
+    </key>
+  </component>
+  <component name="RunDashboard">
+    <option name="ruleStates">
+      <list>
+        <RuleState>
+          <option name="name" value="ConfigurationTypeDashboardGroupingRule" />
+        </RuleState>
+        <RuleState>
+          <option name="name" value="StatusDashboardGroupingRule" />
+        </RuleState>
+      </list>
+    </option>
+  </component>
+  <component name="RunManager" selected="Python.mnist_eval">
+    <configuration default="true" type="JupiterNotebook" factoryName="Jupyter Notebook">
+      <module name="TF" />
+      <option name="INTERPRETER_OPTIONS" value="" />
+      <option name="PARENT_ENVS" value="true" />
+      <envs>
+        <env name="PYTHONUNBUFFERED" value="1" />
+        <env name="LD_LIBRARY_PATH" value="//usr/local/cuda/lib64" />
+      </envs>
+      <option name="SDK_HOME" value="/usr/bin/python2.7" />
+      <option name="WORKING_DIRECTORY" value="" />
+      <option name="IS_MODULE_SDK" value="false" />
+      <option name="ADD_CONTENT_ROOTS" value="true" />
+      <option name="ADD_SOURCE_ROOTS" value="true" />
+      <option name="additionalOptions" value="" />
+      <option name="ipnbHost" value="127.0.0.1" />
+      <option name="ipnbPort" value="8888" />
+    </configuration>
+    <configuration name="forward_propagation" type="PythonConfigurationType" factoryName="Python" temporary="true">
+      <module name="TF" />
+      <option name="INTERPRETER_OPTIONS" value="" />
+      <option name="PARENT_ENVS" value="true" />
+      <envs>
+        <env name="PYTHONUNBUFFERED" value="1" />
+        <env name="LD_LIBRARY_PATH" value="//usr/local/cuda/lib64" />
+      </envs>
+      <option name="SDK_HOME" value="/usr/bin/python2.7" />
+      <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/tests" />
+      <option name="IS_MODULE_SDK" value="true" />
+      <option name="ADD_CONTENT_ROOTS" value="true" />
+      <option name="ADD_SOURCE_ROOTS" value="true" />
+      <option name="SCRIPT_NAME" value="$PROJECT_DIR$/tests/forward_propagation.py" />
+      <option name="PARAMETERS" value="" />
+      <option name="SHOW_COMMAND_LINE" value="false" />
+      <option name="EMULATE_TERMINAL" value="false" />
+      <option name="MODULE_MODE" value="false" />
+    </configuration>
+    <configuration name="mnist_eval" type="PythonConfigurationType" factoryName="Python" temporary="true">
+      <module name="TF" />
+      <option name="INTERPRETER_OPTIONS" value="" />
+      <option name="PARENT_ENVS" value="true" />
+      <envs>
+        <env name="PYTHONUNBUFFERED" value="1" />
+        <env name="LD_LIBRARY_PATH" value="//usr/local/cuda/lib64" />
+      </envs>
+      <option name="SDK_HOME" value="/usr/bin/python2.7" />
+      <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/mnist_restructured" />
+      <option name="IS_MODULE_SDK" value="true" />
+      <option name="ADD_CONTENT_ROOTS" value="true" />
+      <option name="ADD_SOURCE_ROOTS" value="true" />
+      <option name="SCRIPT_NAME" value="$PROJECT_DIR$/mnist_restructured/mnist_eval.py" />
+      <option name="PARAMETERS" value="" />
+      <option name="SHOW_COMMAND_LINE" value="false" />
+      <option name="EMULATE_TERMINAL" value="false" />
+      <option name="MODULE_MODE" value="false" />
+    </configuration>
+    <configuration name="mnist_inference" type="PythonConfigurationType" factoryName="Python" temporary="true">
+      <module name="TF" />
+      <option name="INTERPRETER_OPTIONS" value="" />
+      <option name="PARENT_ENVS" value="true" />
+      <envs>
+        <env name="PYTHONUNBUFFERED" value="1" />
+        <env name="LD_LIBRARY_PATH" value="//usr/local/cuda/lib64" />
+      </envs>
+      <option name="SDK_HOME" value="/usr/bin/python2.7" />
+      <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/mnist_restructured" />
+      <option name="IS_MODULE_SDK" value="true" />
+      <option name="ADD_CONTENT_ROOTS" value="true" />
+      <option name="ADD_SOURCE_ROOTS" value="true" />
+      <option name="SCRIPT_NAME" value="$PROJECT_DIR$/mnist_restructured/mnist_inference.py" />
+      <option name="PARAMETERS" value="" />
+      <option name="SHOW_COMMAND_LINE" value="false" />
+      <option name="EMULATE_TERMINAL" value="false" />
+      <option name="MODULE_MODE" value="false" />
+    </configuration>
+    <configuration name="mnist_optimization" type="PythonConfigurationType" factoryName="Python" temporary="true">
+      <module name="TF" />
+      <option name="INTERPRETER_OPTIONS" value="" />
+      <option name="PARENT_ENVS" value="true" />
+      <envs>
+        <env name="PYTHONUNBUFFERED" value="1" />
+        <env name="LD_LIBRARY_PATH" value="//usr/local/cuda/lib64" />
+      </envs>
+      <option name="SDK_HOME" value="" />
+      <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/mnist_number_recognition" />
+      <option name="IS_MODULE_SDK" value="true" />
+      <option name="ADD_CONTENT_ROOTS" value="true" />
+      <option name="ADD_SOURCE_ROOTS" value="true" />
+      <option name="SCRIPT_NAME" value="$PROJECT_DIR$/mnist_number_recognition/mnist_optimization.py" />
+      <option name="PARAMETERS" value="" />
+      <option name="SHOW_COMMAND_LINE" value="false" />
+      <option name="EMULATE_TERMINAL" value="false" />
+      <option name="MODULE_MODE" value="false" />
+    </configuration>
+    <configuration name="mnist_train" type="PythonConfigurationType" factoryName="Python" temporary="true">
+      <module name="TF" />
+      <option name="INTERPRETER_OPTIONS" value="" />
+      <option name="PARENT_ENVS" value="true" />
+      <envs>
+        <env name="PYTHONUNBUFFERED" value="1" />
+        <env name="LD_LIBRARY_PATH" value="//usr/local/cuda/lib64" />
+      </envs>
+      <option name="SDK_HOME" value="/usr/bin/python2.7" />
+      <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/mnist_restructured" />
+      <option name="IS_MODULE_SDK" value="true" />
+      <option name="ADD_CONTENT_ROOTS" value="true" />
+      <option name="ADD_SOURCE_ROOTS" value="true" />
+      <option name="SCRIPT_NAME" value="$PROJECT_DIR$/mnist_restructured/mnist_train.py" />
+      <option name="PARAMETERS" value="" />
+      <option name="SHOW_COMMAND_LINE" value="false" />
+      <option name="EMULATE_TERMINAL" value="false" />
+      <option name="MODULE_MODE" value="false" />
+    </configuration>
+    <list>
+      <item itemvalue="Python.mnist_optimization" />
+      <item itemvalue="Python.forward_propagation" />
+      <item itemvalue="Python.mnist_inference" />
+      <item itemvalue="Python.mnist_train" />
+      <item itemvalue="Python.mnist_eval" />
+    </list>
+    <recent_temporary>
+      <list>
+        <item itemvalue="Python.mnist_eval" />
+        <item itemvalue="Python.mnist_train" />
+        <item itemvalue="Python.mnist_optimization" />
+        <item itemvalue="Python.mnist_inference" />
+        <item itemvalue="Python.forward_propagation" />
+      </list>
+    </recent_temporary>
+  </component>
+  <component name="SvnConfiguration">
+    <configuration>$USER_HOME$/.subversion</configuration>
+  </component>
+  <component name="TaskManager">
+    <task active="true" id="Default" summary="Default task">
+      <changelist id="e9b46fa1-325b-4259-9fd8-0645dfce4e13" name="Default" comment="" />
+      <created>1530626011215</created>
+      <option name="number" value="Default" />
+      <option name="presentableId" value="Default" />
+      <updated>1530626011215</updated>
+    </task>
+    <task id="LOCAL-00001" summary="record system information for the TF">
+      <created>1530628533126</created>
+      <option name="number" value="00001" />
+      <option name="presentableId" value="LOCAL-00001" />
+      <option name="project" value="LOCAL" />
+      <updated>1530628533126</updated>
+    </task>
+    <task id="LOCAL-00002" summary="some notes for the TF installation">
+      <created>1530634208130</created>
+      <option name="number" value="00002" />
+      <option name="presentableId" value="LOCAL-00002" />
+      <option name="project" value="LOCAL" />
+      <updated>1530634208130</updated>
+    </task>
+    <task id="LOCAL-00003" summary="the first step">
+      <created>1530719525065</created>
+      <option name="number" value="00003" />
+      <option name="presentableId" value="LOCAL-00003" />
+      <option name="project" value="LOCAL" />
+      <updated>1530719525065</updated>
+    </task>
+    <task id="LOCAL-00004" summary="tensorflow basic operations with a NN sample">
+      <created>1531065803472</created>
+      <option name="number" value="00004" />
+      <option name="presentableId" value="LOCAL-00004" />
+      <option name="project" value="LOCAL" />
+      <updated>1531065803473</updated>
+    </task>
+    <task id="LOCAL-00005" summary="mnist dataset training and validation&#10;structure optimization with variable management">
+      <created>1532748042655</created>
+      <option name="number" value="00005" />
+      <option name="presentableId" value="LOCAL-00005" />
+      <option name="project" value="LOCAL" />
+      <updated>1532748042655</updated>
+    </task>
+    <task id="LOCAL-00006" summary="add previous python files">
+      <created>1532750309813</created>
+      <option name="number" value="00006" />
+      <option name="presentableId" value="LOCAL-00006" />
+      <option name="project" value="LOCAL" />
+      <updated>1532750309813</updated>
+    </task>
+    <task id="LOCAL-00007" summary="restructured nn for mnist number recognition, together with saved nn weights, diagrams and photos">
+      <created>1532783605965</created>
+      <option name="number" value="00007" />
+      <option name="presentableId" value="LOCAL-00007" />
+      <option name="project" value="LOCAL" />
+      <updated>1532783605965</updated>
+    </task>
+    <task id="LOCAL-00008" summary="squeeze file structure">
+      <created>1532841325365</created>
+      <option name="number" value="00008" />
+      <option name="presentableId" value="LOCAL-00008" />
+      <option name="project" value="LOCAL" />
+      <updated>1532841325365</updated>
+    </task>
+    <option name="localTasksCounter" value="9" />
+    <servers />
+  </component>
+  <component name="ToolWindowManager">
+    <frame x="227" y="32" width="1414" height="1004" extended-state="0" />
+    <layout>
+      <window_info active="true" content_ui="combo" id="Project" order="0" sideWeight="0.49881798" visible="true" weight="0.19266714" />
+      <window_info anchor="bottom" id="TODO" order="6" />
+      <window_info anchor="bottom" id="Event Log" order="10" sideWeight="0.43278217" side_tool="true" weight="0.32387707" />
+      <window_info anchor="bottom" id="Version Control" order="9" sideWeight="0.5672178" weight="0.32387707" />
+      <window_info anchor="bottom" id="Python Console" order="7" weight="0.3286052" />
+      <window_info anchor="bottom" id="Run" order="2" sideWeight="0.49892163" weight="0.3427896" />
+      <window_info id="Structure" order="1" sideWeight="0.501182" side_tool="true" weight="0.20400308" />
+      <window_info anchor="bottom" id="Terminal" order="8" weight="0.3286052" />
+      <window_info id="Favorites" order="2" sideWeight="0.501182" side_tool="true" weight="0.20400308" />
+      <window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
+      <window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
+      <window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
+      <window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
+      <window_info anchor="bottom" id="Message" order="0" />
+      <window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
+      <window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
+      <window_info anchor="bottom" id="Find" order="1" weight="0.3321513" />
+    </layout>
+  </component>
+  <component name="Vcs.Log.Tabs.Properties">
+    <option name="TAB_STATES">
+      <map>
+        <entry key="MAIN">
+          <value>
+            <State>
+              <option name="RECENTLY_FILTERED_USER_GROUPS">
+                <collection />
+              </option>
+              <option name="RECENTLY_FILTERED_BRANCH_GROUPS">
+                <collection />
+              </option>
+              <option name="COLUMN_ORDER">
+                <list>
+                  <option value="0" />
+                  <option value="1" />
+                  <option value="2" />
+                  <option value="3" />
+                </list>
+              </option>
+            </State>
+          </value>
+        </entry>
+      </map>
+    </option>
+  </component>
+  <component name="VcsContentAnnotationSettings">
+    <option name="myLimit" value="2678400000" />
+  </component>
+  <component name="VcsManagerConfiguration">
+    <MESSAGE value="record system information for the TF" />
+    <MESSAGE value="some notes for the TF installation" />
+    <MESSAGE value="the first step" />
+    <MESSAGE value="tensorflow basic operations with a NN sample" />
+    <MESSAGE value="mnist dataset training and validation&#10;structure optimization with variable management" />
+    <MESSAGE value="add previous python files" />
+    <MESSAGE value="restructured nn for mnist number recognition, together with saved nn weights, diagrams and photos" />
+    <MESSAGE value="squeeze file structure" />
+    <option name="LAST_COMMIT_MESSAGE" value="squeeze file structure" />
+  </component>
+  <component name="XDebuggerManager">
+    <breakpoint-manager>
+      <option name="time" value="8" />
+    </breakpoint-manager>
+  </component>
+  <component name="editorHistoryManager">
+    <entry file="file://$PROJECT_DIR$/mnist_restructured/mnist_inference.py">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="480">
+          <caret line="24" selection-start-line="24" selection-end-line="24" />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/mnist_restructured/mnist_train.py">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="840">
+          <caret line="42" column="45" selection-start-line="42" selection-start-column="45" selection-end-line="42" selection-end-column="45" />
+          <folding>
+            <element signature="e#23#32#0" expanded="true" />
+          </folding>
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/mnist_restructured/mnist_eval.py">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="160">
+          <caret line="15" lean-forward="true" selection-start-line="15" selection-end-line="15" />
+          <folding>
+            <element signature="e#23#34#0" expanded="true" />
+          </folding>
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/mnist_restructured/mnist_inference.py">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="480">
+          <caret line="24" selection-start-line="24" selection-end-line="24" />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/mnist_restructured/mnist_train.py">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="740">
+          <caret line="42" column="45" selection-start-line="42" selection-start-column="45" selection-end-line="42" selection-end-column="45" />
+          <folding>
+            <element signature="e#23#32#0" expanded="true" />
+          </folding>
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/mnist_restructured/mnist_eval.py">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="300">
+          <caret line="15" selection-start-line="15" selection-end-line="15" />
+          <folding>
+            <element signature="e#23#34#0" expanded="true" />
+          </folding>
+        </state>
+      </provider>
+    </entry>
+  </component>
+</project>

+ 30 - 0
LeNet5/accuracy_score_cnn.txt

@@ -0,0 +1,30 @@
+0.9440
+0.9570
+0.9590
+0.9670
+0.9610
+0.9680
+0.9680
+0.9700
+0.9770
+0.9730
+0.9700
+0.9700
+0.9770
+0.9670
+0.9730
+0.9780
+0.9750
+0.9770
+0.9760
+0.9720
+0.9680
+0.9740
+0.9670
+0.9730
+0.9710
+0.9740
+0.9680
+0.9720
+0.9700
+0.9640

+ 30 - 0
LeNet5/accuracy_score_fc.txt

@@ -0,0 +1,30 @@
+0.1340
+0.9750
+0.9800
+0.9800
+0.9820
+0.9820
+0.9830
+0.9840
+0.9830
+0.9830
+0.9830
+0.9830
+0.9830
+0.9830
+0.9830
+0.9830
+0.9830
+0.9830
+0.9830
+0.9830
+0.9830
+0.9830
+0.9830
+0.9830
+0.9830
+0.9830
+0.9830
+0.9830
+0.9830
+0.9830

BIN
LeNet5/images/mnist_result_evaluation.jpg


+ 126 - 0
LeNet5/mnist_eval.py

@@ -0,0 +1,126 @@
+# -*- coding: utf8 -*-
+import time
+import tensorflow as tf
+from tensorflow.examples.tutorials.mnist import input_data
+import matplotlib.pyplot as plt
+import numpy as np
+import mnist_inference
+import mnist_train
+from numpy.random import RandomState
+import os
+
+# generate new random dataset for test in 3 secs after close figure window manually
+EVAL_INTERVAL_SECS = 3
+NUMBER_OF_SAMPLES = 36
+FIG_ROWS = 3
+
+
+# display images and recognition result rather than accuracy diagram
+def evaluation(mnist):
+    with tf.Graph().as_default() as g:
+        x = tf.placeholder(tf.float32, [NUMBER_OF_SAMPLES,
+                                        mnist_inference.IMAGE_SIZE,
+                                        mnist_inference.IMAGE_SIZE,
+                                        mnist_inference.NUM_CHANNELS], name='x-input')
+        y_ = tf.placeholder(tf.float32, [None, mnist_inference.OUTPUT_NODE], name='input-y')
+
+        # replace accuracy with actual recognition result
+        y = mnist_inference.inference(x, False, None)
+        indices = tf.argmax(y, 1)
+        correct_indices = tf.argmax(y_, 1)
+
+        # correct_prediction = tf.equal(tf.argmax(y, 1), tf.argmax(y_, 1))
+        # accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))
+
+        variable_averages = tf.train.ExponentialMovingAverage(mnist_train.MOVING_AVERAGE_DECAY)
+        variables_to_restore = variable_averages.variables_to_restore()
+        saver = tf.train.Saver(variables_to_restore)
+
+        while True:
+            # configure TF to allocate mem properly, rather than consume all GPU mem
+            config = tf.ConfigProto(allow_soft_placement=True)
+            gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=0.4)
+            config.gpu_options.allow_growth = True
+            with tf.Session(config=config) as sess:
+                ckpt = tf.train.get_checkpoint_state(
+                    mnist_train.MODEL_SAVE_PATH
+                )
+                if ckpt and ckpt.model_checkpoint_path:
+                    saver.restore(sess, ckpt.model_checkpoint_path)
+                    rdm = RandomState(int(time.time()))
+                    sample_index = rdm.randint(0, mnist.validation.num_examples - NUMBER_OF_SAMPLES)
+                    xs = mnist.validation.images[sample_index:sample_index + NUMBER_OF_SAMPLES]
+                    validation_feed = {
+                        x: np.reshape(xs, (NUMBER_OF_SAMPLES,
+                                           mnist_inference.IMAGE_SIZE,
+                                           mnist_inference.IMAGE_SIZE,
+                                           mnist_inference.NUM_CHANNELS)),
+                        y_: mnist.validation.labels[sample_index:sample_index + NUMBER_OF_SAMPLES]}
+
+                    # txs = mnist.test.images
+                    # test_feed = {
+                    #     x: np.reshape(txs, (mnist.test.num_examples,
+                    #                         mnist_inference.IMAGE_SIZE,
+                    #                         mnist_inference.IMAGE_SIZE,
+                    #                         mnist_inference.NUM_CHANNELS)),
+                    #     y_: mnist.test.labels}
+                    # # define accuracy score, generate image
+                    # accuracy_score = sess.run(accuracy, feed_dict=test_feed)
+
+                    # get global step from file name
+                    global_step = ckpt.model_checkpoint_path.split('/')[-1].split('-')[-1]
+                    # print("after %s training step(s), validation accuracy = %g" % (global_step, accuracy_score))
+
+                    indices_score, correct_indices_score = sess.run(
+                        [indices, correct_indices], feed_dict=validation_feed)
+                    print("after %s training step(s), validation result = \n%s\n, correct answer: \n%s" \
+                          % (global_step, indices_score, correct_indices_score))
+                    fig = plt.figure(1)
+                    fig.set_size_inches(15, 6)
+                    for n in range(1, NUMBER_OF_SAMPLES + 1):
+                        fig.add_subplot(FIG_ROWS, (NUMBER_OF_SAMPLES / FIG_ROWS + 1), n)
+                        plt.title("predict: [%s]\nanswer: [%s]"
+                                  % (indices_score[n - 1], correct_indices_score[n - 1]))
+                        plt.imshow(mnist.validation.images[sample_index + n - 1].reshape(28, 28))
+                    # fig.add_subplot(2, 3, 1)
+                    # plt.imshow(mnist.validation.images[sample_index].reshape(28, 28))
+                    # fig.add_subplot(2, 3, 2)
+                    # plt.imshow(mnist.validation.images[sample_index + 1].reshape(28, 28))
+                    # fig.add_subplot(2, 3, 3)
+                    # plt.imshow(mnist.validation.images[sample_index + 2].reshape(28, 28))
+                    # fig.add_subplot(2, 3, 4)
+                    # plt.imshow(mnist.validation.images[sample_index + 3].reshape(28, 28))
+                    # fig.add_subplot(2, 3, 5)
+                    # plt.imshow(mnist.validation.images[sample_index + 4].reshape(28, 28))
+                    # fig.add_subplot(2, 3, 6)
+                    # plt.imshow(mnist.validation.images[sample_index + 5].reshape(28, 28))
+                    plt.subplots_adjust(
+                        top=0.95, bottom=0.05, left=0.05, right=0.95, hspace=0.35, wspace=0.6)
+                    try:
+                        os.mkdir('images/')
+                    except:
+                        print("directory already exist")
+
+                    plt.savefig('images/mnist_result_evaluation.jpg', format='jpg')
+                    plt.show()
+
+                else:
+                    print("no checkpoint file found")
+                    return
+
+            time.sleep(EVAL_INTERVAL_SECS)
+
+
+def main(argv=None):
+    mnist = input_data.read_data_sets('../MNIST_data', one_hot=True)
+    print("basic information of mnist dataset")
+    print("mnist training data size: ", mnist.train.num_examples)
+    print("mnist validating data size: ", mnist.validation.num_examples)
+    print("mnist testing data size: ", mnist.test.num_examples)
+    # print("mnist example training data: ", mnist.train.images[0])
+    # print("mnist example training data label", mnist.train.labels[0])
+    evaluation(mnist)
+
+
+if __name__ == '__main__':
+    tf.app.run()

+ 82 - 0
LeNet5/mnist_inference.py

@@ -0,0 +1,82 @@
+# -*- coding: utf8 -*-
+import tensorflow as tf
+
+# define basic params
+INPUT_NODE = 784
+OUTPUT_NODE = 10
+
+IMAGE_SIZE = 28
+NUM_CHANNELS = 1
+NUM_LABELS = 10
+
+CONV1_DEPTH = 6
+CONV1_SIZE = 5
+
+CONV2_DEPTH = 16
+CONV2_SIZE = 5
+
+FC_SIZE = 84
+
+
+def inference(input_tensor, train, regularizer):
+    # define layer1 forward propagation
+    with tf.variable_scope('layer1-conv1'):
+        conv1_weights = tf.get_variable(
+            "weight", [CONV1_SIZE, CONV1_SIZE, NUM_CHANNELS, CONV1_DEPTH],
+            initializer=tf.truncated_normal_initializer(stddev=0.1)
+        )
+        conv1_biases = tf.get_variable("bias", [CONV1_DEPTH], initializer=tf.constant_initializer(0.0))
+        # strides 中间两项表示长宽方向步长1
+        conv1 = tf.nn.conv2d(input_tensor, conv1_weights, strides=[1, 1, 1, 1], padding='SAME')
+        relu1 = tf.nn.relu(tf.nn.bias_add(conv1, conv1_biases))
+
+    # define layer2 forward propagation, max pooling, size 2*2, step 2*2, all 0 filling
+    with tf.variable_scope('layer2-pool1'):
+        pool1 = tf.nn.max_pool(relu1, ksize=[1, 2, 2, 1], strides=[1, 2, 2, 1], padding='SAME')
+
+    with tf.variable_scope('layer3-conv2'):
+        conv2_weights = tf.get_variable(
+            "weight", [CONV2_SIZE, CONV2_SIZE, CONV1_DEPTH, CONV2_DEPTH],
+            initializer=tf.truncated_normal_initializer(stddev=0.1)
+        )
+        conv2_biases = tf.get_variable("bias", [CONV2_DEPTH], initializer=tf.constant_initializer(0.0))
+        # size 5*5, depth 64, step 1, all 0 filling
+        conv2 = tf.nn.conv2d(pool1, conv2_weights, strides=[1, 1, 1, 1, ], padding='SAME')
+        relu2 = tf.nn.relu(tf.nn.bias_add(conv2, conv2_biases))
+
+    with tf.variable_scope('layer4-poll2'):
+        pool2 = tf.nn.max_pool(relu2, ksize=[1, 2, 2, 1], strides=[1, 2, 2, 1], padding='SAME')
+
+    # pool_shape[0] means the num of data from a batch, get_shape->[num, width, height, depth]
+    pool_shape = pool2.get_shape().as_list()
+    nodes = pool_shape[1] * pool_shape[2] * pool_shape[3]
+    reshaped = tf.reshape(pool2, [pool_shape[0], nodes])
+
+    with tf.variable_scope('layer5-fc1'):
+        fc1_weights = tf.get_variable(
+            'weights',
+            [nodes, FC_SIZE],
+            initializer=tf.truncated_normal_initializer(stddev=0.1)
+        )
+        # fc layer regularize
+        if regularizer is not None:
+            tf.add_to_collection('losses', regularizer(fc1_weights))
+        fc1_biases = tf.get_variable('bias', [FC_SIZE], initializer=tf.constant_initializer(0.1))
+
+        fc1 = tf.nn.relu(tf.matmul(reshaped, fc1_weights) + fc1_biases)
+        if train:
+            fc1 = tf.nn.dropout(fc1, 0.5)
+
+    with tf.variable_scope('layer6-fc2'):
+        fc2_weight = tf.get_variable(
+            'weight',
+            [FC_SIZE, NUM_LABELS],
+            initializer=tf.truncated_normal_initializer(stddev=0.1)
+        )
+        if regularizer is not None:
+            tf.add_to_collection('losses', regularizer(fc2_weight))
+        fc2_biases = tf.get_variable('bias', [NUM_LABELS], initializer=tf.constant_initializer(0.1))
+
+        logit = tf.matmul(fc1, fc2_weight)+fc2_biases
+
+    return logit

+ 139 - 0
LeNet5/mnist_train.py

@@ -0,0 +1,139 @@
+# -*- coding: utf8 -*-
+import os
+
+import tensorflow as tf
+from tensorflow.examples.tutorials.mnist import input_data
+import numpy as np
+import matplotlib.pyplot as plt
+import mnist_inference
+
+# define input, output, batch and training params
+
+BATCH_SIZE = 300
+LEARNING_RATE_BASE = 0.8
+LEARNING_RATE_DECAY = 0.99
+REGULARIZATION_RATE = 0.0001
+TRAINING_STEPS = 30000
+MOVING_AVERAGE_DECAY = 0.99
+
+MODEL_SAVE_PATH = "model/"
+MODEL_NAME = "model.ckpt"
+score_filename = "accuracy_score_cnn.txt"
+
+# train a convolutional neural network
+def train(mnist, continue_train=False):
+    x = tf.placeholder(tf.float32, [BATCH_SIZE,
+                                    mnist_inference.IMAGE_SIZE,
+                                    mnist_inference.IMAGE_SIZE,
+                                    mnist_inference.NUM_CHANNELS], name='x-input')
+    y_ = tf.placeholder(tf.float32, [None, mnist_inference.OUTPUT_NODE], name='y-input')
+
+    regularizer = tf.contrib.layers.l2_regularizer(REGULARIZATION_RATE)
+    y = mnist_inference.inference(x, True, regularizer)
+    global_step = tf.Variable(0, trainable=False)
+
+    # moving average, cross entropy, loss function with regularization and learning rate
+    variable_average = tf.train.ExponentialMovingAverage(MOVING_AVERAGE_DECAY, global_step)
+    variable_average_op = variable_average.apply(tf.trainable_variables())
+    cross_entropy = tf.nn.sparse_softmax_cross_entropy_with_logits(logits=y, labels=tf.argmax(y_, 1))
+    cross_entropy_mean = tf.reduce_mean(cross_entropy)
+    loss = cross_entropy_mean + tf.add_n(tf.get_collection('losses'))
+    learning_rate = tf.train.exponential_decay(
+        LEARNING_RATE_BASE,
+        global_step,
+        mnist.train.num_examples / BATCH_SIZE,
+        LEARNING_RATE_DECAY
+    )
+
+    train_step = tf.train.GradientDescentOptimizer(learning_rate).minimize(loss, global_step=global_step)
+    with tf.control_dependencies([train_step, variable_average_op]):
+        train_op = tf.no_op(name='train')
+
+    # initialize persistence class
+    saver = tf.train.Saver()
+
+    config = tf.ConfigProto(allow_soft_placement=True)
+    gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=0.4)
+    config.gpu_options.allow_growth = True
+    with tf.Session(config=config) as sess:
+        if continue_train:
+            ckpt = tf.train.get_checkpoint_state(
+                MODEL_SAVE_PATH
+            )
+            if ckpt and ckpt.model_checkpoint_path:
+                saver.restore(sess, ckpt.model_checkpoint_path)
+        else:
+            sess.run(tf.global_variables_initializer())
+        # create directory
+        try:
+            os.mkdir(MODEL_SAVE_PATH)
+        except:
+            print("directory already exist")
+
+        # define accuracy
+        correct_prediction = tf.equal(tf.arg_max(y, 1), tf.arg_max(y_, 1))
+        accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))
+        test_result = list(range(int(TRAINING_STEPS / 1000)))
+
+        for i in range(TRAINING_STEPS):
+            xs, ys = mnist.train.next_batch(BATCH_SIZE)
+            reshaped_xs = np.reshape(xs, (
+                BATCH_SIZE,
+                mnist_inference.IMAGE_SIZE,
+                mnist_inference.IMAGE_SIZE,
+                mnist_inference.NUM_CHANNELS))
+
+            _, loss_value, step = sess.run([train_op, loss, global_step], feed_dict={x: reshaped_xs, y_: ys})
+
+            txs = mnist.test.images[0:BATCH_SIZE]
+            test_feed = {
+                x: np.reshape(txs, (BATCH_SIZE,
+                                    mnist_inference.IMAGE_SIZE,
+                                    mnist_inference.IMAGE_SIZE,
+                                    mnist_inference.NUM_CHANNELS)),
+                y_: mnist.test.labels[0:BATCH_SIZE]}
+
+            accuracy_score = sess.run(accuracy, feed_dict=test_feed)
+            test_result[int(i/1000)] = accuracy_score
+
+            if i % 1000 == 0:
+                print("after %d training step(s), loss on training batch is %g , validation accuracy = %g" % (
+                    step, loss_value, accuracy_score))
+                saver.save(
+                    sess, os.path.join(MODEL_SAVE_PATH, MODEL_NAME), global_step=global_step
+                )
+
+    np.savetxt(score_filename, test_result, fmt="%0.4f")
+
+    dispImg(test_result, 'accuracy_score')
+    plt.show()
+
+
+def dispImg(test_result, filename):
+    # draw a graph of accuracy using matplotlib
+    iteration_count = range(0, TRAINING_STEPS, 1000)
+    plt.figure(num=1, figsize=(15, 8))
+    plt.title("Plot accuracy", size=20)
+    plt.xlabel("iteration count", size=14)
+    plt.ylabel("accuracy/%", size=14)
+    test_note = [TRAINING_STEPS - 1000, test_result[TRAINING_STEPS / 1000 - 1]]
+    plt.annotate('test-' + str(test_note), xy=(test_note[0], test_note[1]),
+                 xytext=(test_note[0] + 1000, test_note[1] - 0.07), arrowprops=dict(facecolor='black', shrink=0.05))
+    plt.grid(True)
+    plt.plot(iteration_count, test_result, linestyle='-.', marker='X', label='test data')
+    plt.legend(loc="upper left")
+    try:
+        os.mkdir('images/')
+    except:
+        print("directory already exist")
+    plt.savefig('images/%s.png' % filename, format='png')
+
+
+def main(argv=None):
+    mnist = input_data.read_data_sets("../MNIST_data", one_hot=True)
+    print("start")
+    train(mnist, True)
+
+
+if __name__ == '__main__':
+    tf.app.run()

+ 6 - 0
LeNet5/model/checkpoint

@@ -0,0 +1,6 @@
+model_checkpoint_path: "model.ckpt-29001"
+all_model_checkpoint_paths: "model.ckpt-25001"
+all_model_checkpoint_paths: "model.ckpt-26001"
+all_model_checkpoint_paths: "model.ckpt-27001"
+all_model_checkpoint_paths: "model.ckpt-28001"
+all_model_checkpoint_paths: "model.ckpt-29001"

BIN
LeNet5/model/model.ckpt-17501.data-00000-of-00001


BIN
LeNet5/model/model.ckpt-17501.index


BIN
LeNet5/model/model.ckpt-17501.meta


BIN
LeNet5/model/model.ckpt-20001.data-00000-of-00001


BIN
LeNet5/model/model.ckpt-20001.index


BIN
LeNet5/model/model.ckpt-20001.meta


BIN
LeNet5/model/model.ckpt-22501.data-00000-of-00001


BIN
LeNet5/model/model.ckpt-22501.index


BIN
LeNet5/model/model.ckpt-22501.meta


BIN
LeNet5/model/model.ckpt-25001.data-00000-of-00001


BIN
LeNet5/model/model.ckpt-25001.index


BIN
LeNet5/model/model.ckpt-25001.meta


BIN
LeNet5/model/model.ckpt-2501.data-00000-of-00001


BIN
LeNet5/model/model.ckpt-2501.index


BIN
LeNet5/model/model.ckpt-2501.meta


BIN
LeNet5/model/model.ckpt-26001.data-00000-of-00001


BIN
LeNet5/model/model.ckpt-26001.index


BIN
LeNet5/model/model.ckpt-26001.meta


BIN
LeNet5/model/model.ckpt-27001.data-00000-of-00001


BIN
LeNet5/model/model.ckpt-27001.index


BIN
LeNet5/model/model.ckpt-27001.meta


BIN
LeNet5/model/model.ckpt-27501.data-00000-of-00001


BIN
LeNet5/model/model.ckpt-27501.index


BIN
LeNet5/model/model.ckpt-27501.meta


BIN
LeNet5/model/model.ckpt-28001.data-00000-of-00001


BIN
LeNet5/model/model.ckpt-28001.index


BIN
LeNet5/model/model.ckpt-28001.meta


BIN
LeNet5/model/model.ckpt-29001.data-00000-of-00001


BIN
LeNet5/model/model.ckpt-29001.index


BIN
LeNet5/model/model.ckpt-29001.meta


BIN
LeNet5/model/model.ckpt-7501.data-00000-of-00001


BIN
LeNet5/model/model.ckpt-7501.index


BIN
LeNet5/model/model.ckpt-7501.meta


BIN
mnist_number_recognition/images/mnist_accuracy_evaluation.png


BIN
mnist_number_recognition/images/with EMA.png


BIN
mnist_number_recognition/images/without EMA.png


+ 18 - 13
mnist_number_recognition/mnist_optimization.py

@@ -23,7 +23,7 @@ BATCH_SIZE = 1000
 LEARNING_RATE_BASE = 0.8
 LEARNING_RATE_DECAY = 0.999
 REGULARIZATION_RATE = 0.0001
-TRAINING_STEPS = 100000
+TRAINING_STEPS = 200000
 MOVING_AVERAGE_DECAY = 0.99
 
 
@@ -95,7 +95,8 @@ def train(mnist):
     with tf.control_dependencies([train_step, variable_averages_op]):
         train_op = tf.no_op(name="train")
 
-    correct_prediction = tf.equal(tf.arg_max(average_y, 1), tf.arg_max(y_, 1))
+    # correct_prediction = tf.equal(tf.arg_max(average_y, 1), tf.arg_max(y_, 1))
+    correct_prediction = tf.equal(tf.arg_max(y, 1), tf.arg_max(y_, 1))
     accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))
 
     with tf.Session() as sess:
@@ -131,6 +132,20 @@ def train(mnist):
         saver = tf.train.Saver()
         saver.export_meta_graph("model.ckpt.meda.json", as_text=True)
 
+    dispImg(validation_result, test_result, "with EMA")
+    # img_vector = mnist.train.images[5]
+    # img_length = int(np.sqrt(INPUT_NODE))
+    # img = np.ndarray([img_length, img_length])
+    # # print "image size: ", img_length, "*", img_length
+    # for c in range(INPUT_NODE):
+    #     # print "image indices: ", c / img_length, "*", c % img_length
+    #     img[c / img_length][c % img_length] = img_vector[c]
+    # plt.figure(num=2, figsize=(15, 8))
+    # plt.imshow(img)
+    plt.show()
+
+
+def dispImg(validation_result, test_result, filename):
     # draw a graph of accuracy using matplotlib
     iteration_count = range(0, TRAINING_STEPS, 1000)
     plt.figure(num=1, figsize=(15, 8))
@@ -151,17 +166,7 @@ def train(mnist):
         os.mkdir('images/')
     except:
         print("directory already exist")
-    plt.savefig('images/mnist_accuracy_evaluation.png', format='png')
-    img_vector = mnist.train.images[5]
-    img_length = int(np.sqrt(INPUT_NODE))
-    img = np.ndarray([img_length, img_length])
-    # print "image size: ", img_length, "*", img_length
-    for c in range(INPUT_NODE):
-        # print "image indices: ", c / img_length, "*", c % img_length
-        img[c / img_length][c % img_length] = img_vector[c]
-    plt.figure(num=2, figsize=(15, 8))
-    plt.imshow(img)
-    plt.show()
+    plt.savefig('images/%s.png' % filename, format='png')
 
 
 def main(argv=None):

Dosya farkı çok büyük olduğundan ihmal edildi
+ 11 - 11
mnist_number_recognition/model.ckpt.meda.json


BIN
mnist_restructured/images/mnist_result_evaluation.jpg


+ 7 - 6
mnist_restructured/mnist_eval.py

@@ -10,7 +10,7 @@ import os
 
 # generate new random dataset for test in 3 secs after close figure window manually
 EVAL_INTERVAL_SECS = 3
-NUMBER_OF_SAMPLES = 12
+NUMBER_OF_SAMPLES = 36
 FIG_ROWS = 3
 
 
@@ -61,9 +61,10 @@ def evaluation(mnist):
                         [indices, correct_indices], feed_dict=validation_feed)
                     # accuracy_score = sess.run(accuracy, feed_dict=validation_feed)
                     # print "after %s training step(s), validation accuracy = %g" % (global_step, accuracy_score)
-                    print "after %s training step(s), validation result = %s, correct answer: %s" \
-                          % (global_step, indices_score, correct_indices_score)
+                    print("after %s training step(s), validation result = \n%s\n, correct answer: \n%s" \
+                          % (global_step, indices_score, correct_indices_score))
                     fig = plt.figure(1)
+                    fig.set_size_inches(15,6)
                     for n in range(1, NUMBER_OF_SAMPLES + 1):
                         fig.add_subplot(FIG_ROWS, (NUMBER_OF_SAMPLES / FIG_ROWS + 1), n)
                         plt.title("predict: [%s]\nanswer: [%s]"
@@ -82,7 +83,7 @@ def evaluation(mnist):
                     # fig.add_subplot(2, 3, 6)
                     # plt.imshow(mnist.validation.images[sample_index + 5].reshape(28, 28))
                     plt.subplots_adjust(
-                        top=0.9, bottom=0.1, left=0.1, right=0.9, hspace=0.5, wspace=0.55)
+                        top=0.95, bottom=0.05, left=0.05, right=0.95, hspace=0.5, wspace=0.55)
                     try:
                         os.mkdir('images/')
                     except:
@@ -91,14 +92,14 @@ def evaluation(mnist):
                     plt.show()
 
                 else:
-                    print "no checkpoint file found"
+                    print("no checkpoint file found")
                     return
 
             time.sleep(EVAL_INTERVAL_SECS)
 
 
 def main(argv=None):
-    mnist = input_data.read_data_sets('MNIST_data', one_hot=True)
+    mnist = input_data.read_data_sets('../MNIST_data', one_hot=True)
     evaluation(mnist)
 
 

+ 4 - 4
mnist_restructured/mnist_train.py

@@ -64,16 +64,16 @@ def train(mnist):
             _, loss_value, step = sess.run([train_op, loss, global_step], feed_dict={x: xs, y_: ys})
 
             if i % 2500 == 0:
-                print "after %d training step(s), loss on training batch is %g " % (step, loss_value)
+                print("after %d training step(s), loss on training batch is %g " % (step, loss_value))
                 saver.save(
                     sess, os.path.join(MODEL_SAVE_PATH, MODEL_NAME), global_step=global_step
                 )
 
 
 def main(argv=None):
-    print "start"
-    mnist = input_data.read_data_sets("MNIST_data", one_hot=True)
-    print "start"
+    print("start")
+    mnist = input_data.read_data_sets("../MNIST_data", one_hot=True)
+    print("start")
     train(mnist)
 
 

BIN
mnist_restructured/model/model.ckpt-17501.data-00000-of-00001


BIN
mnist_restructured/model/model.ckpt-17501.index


BIN
mnist_restructured/model/model.ckpt-17501.meta


BIN
mnist_restructured/model/model.ckpt-20001.data-00000-of-00001


BIN
mnist_restructured/model/model.ckpt-20001.index


BIN
mnist_restructured/model/model.ckpt-20001.meta


BIN
mnist_restructured/model/model.ckpt-22501.data-00000-of-00001


BIN
mnist_restructured/model/model.ckpt-22501.index


BIN
mnist_restructured/model/model.ckpt-22501.meta


BIN
mnist_restructured/model/model.ckpt-25001.data-00000-of-00001


BIN
mnist_restructured/model/model.ckpt-25001.index


BIN
mnist_restructured/model/model.ckpt-25001.meta


BIN
mnist_restructured/model/model.ckpt-27501.data-00000-of-00001


BIN
mnist_restructured/model/model.ckpt-27501.index


BIN
mnist_restructured/model/model.ckpt-27501.meta