GithubHelp home page GithubHelp logo

geekwolverine / tensorflow-basic-exercises Goto Github PK

View Code? Open in Web Editor NEW

This project forked from terrytangyuan/tensorflow-basic-exercises

0.0 0.0 0.0 1.2 MB

Exercises for TensorFlow Tutorial

Python 100.00%

tensorflow-basic-exercises's Introduction

TensorFlow Basic Exercises

This repo contains exercises for basic TensorFlow tutorial.

Software Requirements

You need to have Python and pip installed. Then install TensorFlow via pip install tensorflow. Consult this page if you want to customize your setup.

To test your installation, clone this repo and then run python demo.py. No error is expected if installation ws successful. You should expect the following at the end of the output:

Optimization Finished!
Accuracy: 0.9256

Instruction

The Python script demo.py provides a basic example for logistic regression using TensorFlow on MNIST hand-written digit data. All the necessary steps, including data preprocessing, model building, and model evaluation, have been done for you so you can focus on small parts of the program. You are expected to make small modifications to the Python script demo.py to achieve the goals of the following exercises to get more familiar with TensorFlow's basics.

Exercises

Exercise 1: Minimize error using cross entropy as the cost function

  • Hint a: Definition of cross entropy on Wikipedia.
  • Hint b: You'll need to use tf.reduce_mean, tf.reduce_sum, and tf.log.

Exercise 2: Apply exponential learning rate decay

  • Hint a: TensorFlow has a built-in function for exponential decay. See API Documentation for this here.
  • Hint b: You can use global_step = tf.Variable(0, trainable=False) to initialize global step.

Exercise 3: Apply early stopping when a condition is met

  • Hint a: Calculate the absolute value of the difference between current average cost and previous average cost.
  • Hint b: When there's no much different, exit the for loop.

Exercise 4: Apply L1 regularization to weights

  • Hint a: Definition of L1 regularization.
  • Hint b: Some functions you'll need are: tf.multiply, tf.reduce_sum, tf.abs.
  • Hint c: Apply this regularization term to when constructing the model.

Exercise 5: What else can you do to achieve higher accuracy (minimum 0.94)?

  • Hint: You can tune learning_rate, change optimizers, change initializers, change cost function, more training steps, advanced early stoping, etc. Be creative!

Maintenance

Please contact Yuan Tang ([email protected]) if you have any questions or open an issue.

Credits

Some screenshots are adopted from TensorFlow Dev Summit, TensorFlow paper, and other online resources. Thanks!

tensorflow-basic-exercises's People

Contributors

terrytangyuan avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.