{"id":15562450,"url":"https://github.com/zvyn/yatt","last_synced_at":"2025-03-29T04:48:25.653Z","repository":{"id":150150516,"uuid":"79628517","full_name":"zvyn/yatt","owner":"zvyn","description":"My resullt of following the tutorial at https://www.tensorflow.org/tutorials/mnist/beginners/.","archived":false,"fork":false,"pushed_at":"2017-02-02T01:00:47.000Z","size":224,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-03T14:46:48.351Z","etag":null,"topics":["mnist-classification","tensorflow","tutorial"],"latest_commit_sha":null,"homepage":null,"language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zvyn.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-01-21T06:30:47.000Z","updated_at":"2017-02-01T23:59:57.000Z","dependencies_parsed_at":null,"dependency_job_id":"e6a8aabd-f9ab-48aa-8634-ff76b5b254e2","html_url":"https://github.com/zvyn/yatt","commit_stats":{"total_commits":9,"total_committers":1,"mean_commits":9.0,"dds":0.0,"last_synced_commit":"61ae1f24fe0948ee8d9c8eaf6ff7352158982f90"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zvyn%2Fyatt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zvyn%2Fyatt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zvyn%2Fyatt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zvyn%2Fyatt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zvyn","download_url":"https://codeload.github.com/zvyn/yatt/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246140547,"owners_count":20729798,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["mnist-classification","tensorflow","tutorial"],"created_at":"2024-10-02T16:14:55.710Z","updated_at":"2025-03-29T04:48:25.618Z","avatar_url":"https://github.com/zvyn.png","language":"HTML","readme":"# MNIST For ML Beginners\n\nImplementation of the [tutorial](https://www.tensorflow.org/tutorials/mnist/beginners/) plus some code to evaluate single files at the end.\n\nType `make` on the command line to install dependencies and run the notebook.\n\n\n```python\nfrom tensorflow.examples.tutorials.mnist import input_data\nmnist = input_data.read_data_sets(\"MNIST_data/\", one_hot=True)\n```\n\n    Extracting MNIST_data/train-images-idx3-ubyte.gz\n    Extracting MNIST_data/train-labels-idx1-ubyte.gz\n    Extracting MNIST_data/t10k-images-idx3-ubyte.gz\n    Extracting MNIST_data/t10k-labels-idx1-ubyte.gz\n\n\n\n```python\nimport tensorflow as tf\nimport numpy as np\n```\n\n\n```python\nx = tf.placeholder(tf.float32, [None, 784])\nW = tf.Variable(tf.zeros([784, 10]))\nb = tf.Variable(tf.zeros([10]))\ny = tf.nn.softmax(tf.matmul(x, W) + b)\n```\n\n\n```python\ny_ = tf.placeholder(tf.float32, [None, 10])\ncross_entropy = tf.reduce_mean(-tf.reduce_sum(y_ * tf.log(y), reduction_indices=[1]))\ntrain_step = tf.train.GradientDescentOptimizer(0.5).minimize(cross_entropy)\n```\n\n\n```python\ninit = tf.global_variables_initializer()\n```\n\n\n```python\nsession = tf.Session()\nsession.run(init)\n```\n\n\n```python\nfor i in range(1000):\n    batch_xs, batch_ys = mnist.train.next_batch(100)\n    session.run(train_step, feed_dict={x: batch_xs, y_: batch_ys})\n```\n\n\n```python\ncorrect_prediction = tf.equal(tf.argmax(y,1), tf.argmax(y_,1))\naccuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))\nprint(session.run(accuracy, feed_dict={x: mnist.test.images, y_: mnist.test.labels}))\n```\n\n    0.917\n\n\n_(end of the tutorial)_\n___________________\n\n## Parse single files using the tensors above\n\n\n```python\nimport operator\n\ndef judge_file(filename, comp=None):\n    with open(filename, 'rb') as f:\n        pixels = []\n        while True:\n            try:\n                pixels.append(f.read(1)[0])\n            except IndexError:\n                break\n\n    result = session.run(y, feed_dict={x: [np.asfarray([1 - (pixel / 255) for pixel in pixels])]})\n\n    d, p = max(enumerate(result[0]), key=operator.itemgetter(1))\n    if d == comp:\n        print(\"{}: {}, {:.4}%\".format(filename, d, p * 100))\n    return max(enumerate(result[0]), key=operator.itemgetter(1))\n\n```\n\n\n```python\ndict(enumerate([judge_file('single_files/test{}.data'.format(n), n) for n in range(10)]))\n```\n\n    single_files/test0.data: 0, 99.89%\n    single_files/test2.data: 2, 99.85%\n    single_files/test3.data: 3, 100.0%\n    single_files/test4.data: 4, 97.75%\n    single_files/test5.data: 5, 66.26%\n\n\n\n\n\n    {0: (0, 0.99892777),\n     1: (8, 0.86384517),\n     2: (2, 0.99845934),\n     3: (3, 0.99999487),\n     4: (4, 0.97749537),\n     5: (5, 0.66259474),\n     6: (5, 0.97694141),\n     7: (3, 0.79184127),\n     8: (3, 0.98323917),\n     9: (3, 0.49540526)}\n\n\n\n\n```python\njudge_file('single_files/Untitled.data')\n```\n\n\n\n\n    (5, 0.73703039)\n\n\n\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzvyn%2Fyatt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzvyn%2Fyatt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzvyn%2Fyatt/lists"}