TensorFlow Quick Reference Table – Cheat Sheet.
TensorFlow cheat sheet. This module introduces basic functions for computer vision and sequential data (ex: text) # Build a graph: inputimg = tf.placeholder(tf.float32, batchsize, height, width, channels) filterimg = tf.Variable(tf.randomuniform(7,7,3,targetchannels)) #strides:, padding can take the values 'SAME' to. Cheat Sheet 9: HackerNoon To understand Tensorflow, you must understand Deep Learning. This cheat sheet is one to keep handy as a dog-eared reference in the desk drawer or right next to your working laptop. Camron will take you from beginning to end understanding Tensorflow and deep learning easier with explanations plus the best resources. TensorFlow is an end-to-end open-source platform from Google developed to address the needs of machine learning. This cheat sheet embraces: the basics of data set management and feature engineering; a reference machine learning workflow with TensorFlow 2.0; model serialization and deserialization examples.
TensorFlow is very popular deep learning library, with its complexity can be overwhelming especially for new users. Here is a short summary of often used functions, if you want to download it in pdf it is available here:
If you find it useful please share on social media.
Import TensorFlow: | |
import tensorflow as tf | |
Basic math operations: | |
tf.add() | sum |
tf.subtract() | substraction |
tf.multiply() | multiplication |
tf.div() | division |
tf.mod() | module |
tf.abs() | absolute value |
tf.negative() | negative value |
tf.sign() | return sign |
tf.reciprocal() | reciprocal |
tf.square() | square |
tf.round() | nearest intiger |
tf.sqrt() | square root |
tf.pow() | power |
tf.exp() | exponent |
tf.log() | logarithm |
tf.maximum() | maximum |
tf.minimum() | minimum |
tf.cos() | cosine |
tf.sin() | sine |
Basic operations on tensors: | |
tf.string_to_number() | converts string to numeric type |
tf.cast() | casts to new type |
tf.shape() | returns shape of tensor |
tf.reshape() | reshapes tensor |
tf.diag() | creates tensor with given diagonal values |
tf.zeros() | creates tensor with all elements set to zero |
tf.fill() | creates tensor with all elements set given value |
tf.concat() | concatenates tensors |
tf.slice() | extracts slice from tensor |
tf.transpose() | transpose the argument |
tf.matmul() | matrices multiplication |
tf.matrix_determinant() | determinant of matrices |
tf.matrix_inverse() | computes inverse of matrices |
Control Flow: | |
tf.while_loop() | repeat body while condition true |
tf.case() | case operator |
tf.count_up_to() | incriments ref untill limit |
tf.tuple() | groups tensors together |
Logical/Comparison Operators: | |
tf.equal() | returns truth value element-wise |
tf.not_equal() | returns truth value of X!=Y |
tf.less() | returns truth value of X |
tf.less_equal() | returns truth value of X<=Y |
tf.greater() | returns truth value of X>Y |
tf.greater_equal() | returns truth value of X>=Y |
tf.is_nan() | returns which elements are NaN |
tf.logical_and() | returns truth value of ‘AND' for given tensors |
tf.logical_or() | returns truth value of ‘OR' for given tensors |
tf.logical_not() | returns truth value of ‘NOT' for given tensors |
tf.logical_xor() | returns truth value of ‘XOR' for given tensors |
Working with Images: | |
tf.image.decode_image() | converts image to tensor type uint8 |
tf.image.resize_images() | resize images |
tf.image.resize_image_with_crop_or_pad() | resize image by cropping or padding |
tf.image.flip_up_down() | flip image horizontally |
tf.image.rot90() | rotate image 90 degrees counter-clockwise |
tf.image.rgb_to_grayscale() | converts image from RGB to grayscale |
tf.image.per_image_standardization() | scales image to zero mean and unit norm |
Neural Networks: | |
tf.nn.relu() | rectified linear activation function |
tf.nn.softmax() | softmax activation function |
tf.nn.sigmoid() | sigmoid activation function |
tf.nn.tanh() | hyperbolic tangent activation function |
tf.nn.dropout | dropout |
tf.nn.bias_add | adds bias to value |
tf.nn.all_candidate_sampler() | set of all classes |
tf.nn.weighted_moments() | returns mean and variance |
tf.nn.softmax_cross_entropy_with_logits() | softmax cross entropy |
tf.nn.sigmoid_cross_entropy_with_logits() | sigmoid cross entropy |
tf.nn.l2_normalize() | normalization using L2 Norm |
tf.nn.l2_loss() | L2 loss |
tf.nn.dynamic_rnn() | RNN specified by given cell |
tf.nn.conv2d() | 2D convolutions given 4D input |
tf.nn.conv1d() | 1D convolution given 3D input |
tf.nn.batch_normalization() | batch normalization |
tf.nn.xw_plus_b() | computes matmul(x,weights)+biases |
High level Machine Learning: | |
tf.contrib.keras | Keras API as high level API for TensorFlow |
tf.contrib.layers.one_hot_column() | one hot encoding |
tf.contrib.learn.LogisticRegressor() | logistic regression |
tf.contrib.learn.DNNClassifier() | DNN classifier |
tf.contrib.learn.DynamicRnnEstimator() | Rnn Estimator |
tf.contrib.learn.KMeansClustering() | K-Means Clusstering |
tf.contrib.learn.LinearClassifier() | linear classifier |
tf.contrib.learn.LinearRegressor() | linear regressor |
tf.contrib.learn.extract_pandas_data() | extract data from Pandas dataframe |
tf.contrib.metrics.accuracy() | accuracy |
tf.contrib.metrics.auc_using_histogram() | AUC |
tf.contrib.metrics.confusion_matrix() | confusion matrix |
tf.contrib.metrics.streaming_mean_absolute_error() | mean absolute error |
tf.contrib.rnn.BasicLSTMCell() | basic lstm cell |
tf.contrib.rnn.BasicRNNCell() | basic rnn cell |
Placeholders and Variables: | |
tf.placeholder() | defines placeholder |
tf.Variable(tf.random_normal([3, 4], stddev=0.1) | defines variable |
tf.Variable(tf.zeros([50]), name='x') | defines variable |
tf.global_variables_initializer() | initialize global variables |
tf.local_variables_initializer() | initialize local variables |
with tf.device('/cpu:0'): | pin variable to CPU |
v = tf.Variable() | |
with tf.device('/gpu:0'): | pin variable to GPU |
v = tf.Variable() | |
sess = tf.Session() | run session |
sess.run() | |
sess.close() | |
with tf.Session() as session: | run session(2) |
session.run() | |
saver=tf.train.Saver() | Saving and restoring variables. |
saver.save(sess,'file_name') | |
saver.restore(sess,'file_name') | |
Working with Data: | |
tf.decode_csv() | converts csv to tensors |
tf.read_file() | reads file |
tf.write_file() | writes to file |
tf.train.batch() | creates batches of tensors |
Was the above useful? Please share with others on social media.
If you want to look for more information, check some free online courses available at coursera.org, edx.org or udemy.com.
Recommended reading list:
Hands-On Machine Learning with Scikit-Learn and TensorFlow: Concepts, Tools, and Techniques to Build Intelligent Systems Through a series of recent breakthroughs, deep learning has boosted the entire field of machine learning. Now, even programmers who know close to nothing about this technology can use simple, efficient tools to implement programs capable of learning from data. This practical book shows you how. By using concrete examples, minimal theory, and two production-ready Python frameworks—scikit-learn and TensorFlow—author Aurélien Géron helps you gain an intuitive understanding of the concepts and tools for building intelligent systems. You'll learn a range of techniques, starting with simple linear regression and progressing to deep neural networks. With exercises in each chapter to help you apply what you've learned, all you need is programming experience to get started. Explore the machine learning landscape, particularly neural nets Use scikit-learn to track an example machine-learning project end-to-end Explore several training models, including support vector machines, decision trees, random forests, and ensemble methods Use the TensorFlow library to build and train neural nets Dive into neural net architectures, including convolutional nets, recurrent nets, and deep reinforcement learning Learn techniques for training and scaling deep neural nets Apply practical code examples without acquiring excessive machine learning theory or algorithm details |
TensorFlow Machine Learning Cookbook This guide starts with the fundamentals of the TensorFlow library which includes variables, matrices, and various data sources. Moving ahead, you will get hands-on experience with Linear Regression techniques with TensorFlow. The next chapters cover important high-level concepts such as neural networks, CNN, RNN, and NLP. Once you are familiar and comfortable with the TensorFlow ecosystem, the last chapter will show you how to take it to production. What you will learn Become familiar with the basics of the TensorFlow machine learning library Get to know Linear Regression techniques with TensorFlow Learn SVMs with hands-on recipes Implement neural networks and improve predictions Apply NLP and sentiment analysis to your data Master CNN and RNN through practical recipes Take TensorFlow into production |
Learning TensorFlow: A Guide to Building Deep Learning Systems TensorFlow is currently the leading open-source software for deep learning, used by a rapidly growing number of practitioners working on computer vision, Natural Language Processing (NLP), speech recognition, and general predictive analytics. This book is an end-to-end guide to TensorFlow designed for data scientists, engineers, students and researchers. With this book you will learn how to: Get up and running with TensorFlow, rapidly and painlessly Build and train popular deep learning models for computer vision and NLP Apply your advanced understanding of the TensorFlow framework to build and adapt models for your specific needs Train models at scale, and deploy TensorFlow in a production setting |
TensorFlow for Machine Intelligence: A Hands-On Introduction to Learning Algorithms TensorFlow, a popular library for machine learning, embraces the innovation and community-engagement of open source, but has the support, guidance, and stability of a large corporation. Because of its multitude of strengths, TensorFlow is appropriate for individuals and businesses ranging from startups to companies as large as, well, Google. TensorFlow is currently being used for natural language processing, artificial intelligence, computer vision, and predictive analytics. TensorFlow, open sourced to the public by Google in November 2015, was made to be flexible, efficient, extensible, and portable. Computers of any shape and size can run it, from smartphones all the way up to huge computing clusters. This book is for anyone who knows a little machine learning (or not) and who has heard about TensorFlow, but found the documentation too daunting to approach. It introduces the TensorFlow framework and the underlying machine learning concepts that are important to harness machine intelligence. After reading this book, you should have a deep understanding of the core TensorFlow API. |
Machine Learning with TensorFlow Being able to make near-real-time decisions is becoming increasingly crucial. To succeed, we need machine learning systems that can turn massive amounts of data into valuable insights. But when you're just starting out in the data science field, how do you get started creating machine learning applications? The answer is TensorFlow, a new open source machine learning library from Google. The TensorFlow library can take your high level designs and turn them into the low level mathematical operations required by machine learning algorithms. Machine Learning with TensorFlow teaches readers about machine learning algorithms and how to implement solutions with TensorFlow. It starts with an overview of machine learning concepts and moves on to the essentials needed to begin using TensorFlow. Each chapter zooms into a prominent example of machine learning. Readers can cover them all to master the basics or skip around to cater to their needs. By the end of this book, readers will be able to solve classification, clustering, regression, and prediction problems in the real world. |
Have a little time to learn Tensorflow 2.0 with your Machine Learning? In this article, I have put together the 10 best Tensorflow cheat sheets for you to hang on the wall above your desk. Whenever you need a reference, keep these handy cheat sheets available!!
Cheat Sheet 1: BecomingHuman.AI
becominghuman.ai has multiple cheat sheets but this one I have found to be one of the best. Easy to read and understand, this cheat sheet is great for beginners and advanced Tensorflow learners alike!
Pros: Rated ‘E' for everyone.
Cons: Color can be distracting
Cheat Sheet 2: Altoros
Altoros is another great website to find cheat sheets for machine learning on!! They cover a wide range of subjects. This Tensorflow cheat sheet is 3 pages long but it is totality worth the wealth of information you can receive.
Pros: Easy to read and understand.
Cons: Condensed information can be difficult for some readers.
Cheat Sheet 3: Tech Republic
This cheat sheet from Tech Republic is chock full of information for you! Including an introduction, how to begin, top competitors and additional resources. This is great if you are looking to become an IT Pro
Pros: Great for those who are looking to upgrade their skills.
Cons: It is a lot of reading material (8 pages, condensed)
Cheat Sheet 4: Dummies
Sometimes, the best way to learn is from a dummy!! Tensorflow for dummies is a great way to get an introduction to Tensorflow, what it is and how it works. Perfect for beginners in machine learning!
Pros: Great information for beginners
Cons: Condensed information, no working examples
Cheat Sheet 5: TensorFlow
Cons: It is a lot of reading material (8 pages, condensed)
Cheat Sheet 4: Dummies
Sometimes, the best way to learn is from a dummy!! Tensorflow for dummies is a great way to get an introduction to Tensorflow, what it is and how it works. Perfect for beginners in machine learning!
Pros: Great information for beginners
Cons: Condensed information, no working examples
Cheat Sheet 5: TensorFlow
To learn Tensorflow, one must go to Tensorflow.org! This website and cheat sheet will teach you everything you need to learn Tensorflow correctly and effectively. There is a lot of materials here so be prepared for a lengthy read! Great for beginners and Advanced Tensorflowers!
Pros: Rated ‘E' for everyone, the best way to Tensorflow.
Cons: Can be confusing to the absolute beginner.
Cheat Sheet 6: Github
This is a really great cheat sheet written by Patrick on Github! He shows examples and syntax. This is a great sheet for all Tensorflow learners!!
Pros: Rated ‘E' for everyone.
Cons: None that I can see.
Cheat sheet 7: Stanford.edu
This cheat sheet shows you the ins and outs of Tensorflow what it is, how it works and how it compares to other data science tools compare. Easily readable for beginners and advanced Tensorflow users alike.
Pros: Easy to understand
Cons: None that I can see
Cheat Sheet 8: Tensorflow Core
This cheat sheet is from Tensorflow Core. It shows api documentation for Tensorflow in Python!! Alongside other languages, it shows the correct explanation and syntax for the method you are trying to perform.
Tensorflow Cheat Sheet 2020
Pros: Easy to read, rated ‘E' for everyone.
Cons: none that I can see.
Cheat Sheet 9: HackerNoon
To understand Tensorflow, you must understand Deep Learning. This cheat sheet is one to keep handy as a dog-eared reference in the desk drawer or right next to your working laptop.
Camron will take you from beginning to end understanding Tensorflow and deep learning easier with explanations plus the best resources. This is a great resource for those who are serious about looking into Data Science as a career with Python and Tensorflow.
Pros: Tons of resources, rated ‘E' for everyone.
Cons: A lot of research materials and reading.
Cheat Sheet 10: Cheatography
This cheat sheet will show you the types of models from machine learning you can build with Tensorflow!! It has graphics, explanations and examples on what you need to know for Tensorflow, Machine and Deep Learning!
Pros: Rated ‘E' for everyone
Cons: None that I can see.
Tensorflow 2 Cheat Sheet
Thank you for joining me on another journey to find the top 10 best cheat sheets on Tensorflow! I hope that they are useful to you on your journey in Deep Learning and Tensorflow!
Related Articles: