{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Introduction to TensorFlow\n", "> Before you can build advanced models in TensorFlow 2.0, you will first need to understand the basics. In this chapter, you’ll learn how to define constants and variables, perform tensor addition and multiplication, and compute derivatives. Knowledge of linear algebra will be helpful, but not necessary. This is the Summary of lecture \"Introduction to TensorFlow in Python\", via datacamp.\n", "\n", "- toc: true \n", "- badges: true\n", "- comments: true\n", "- author: Chanseok Kang\n", "- categories: [Python, Datacamp, Tensorflow-Keras, Deep_Learning]\n", "- image: images/tf.png" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'2.1.0'" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import tensorflow as tf\n", "import pandas as pd\n", "import numpy as np\n", "\n", "tf.__version__" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Constants and variables\n", "- Tensorflow\n", " - Open-source library for graph-based numerical computation\n", " - Low and high level API\n", " - Addition, multiplication, differentiation\n", " - Machine Learning models\n", " - In v2.0\n", " - Eager execution by default\n", " - Model building with Keras and Estimators\n", "- Tensor\n", " - Generalization of vectors and matrices\n", " - Collection of numbers\n", " - Specific shape" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Defining data as constants\n", "Throughout this course, we will use `tensorflow` version 2.1 and will exclusively import the submodules needed to complete each exercise. \n", "\n", "you will use it to transform a numpy array, `credit_numpy`, into a tensorflow constant, `credit_constant`. This array contains feature columns from a dataset on credit card holders.\n", "\n", "Note that tensorflow version 2.0 allows you to use data as either a numpy array or a tensorflow constant object. Using a constant will ensure that any operations performed with that object are done in tensorflow." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | 0 | \n", "1 | \n", "2 | \n", "3 | \n", "
---|---|---|---|---|
0 | \n", "2.0 | \n", "1.0 | \n", "24.0 | \n", "3913.0 | \n", "
1 | \n", "2.0 | \n", "2.0 | \n", "26.0 | \n", "2682.0 | \n", "
2 | \n", "2.0 | \n", "2.0 | \n", "34.0 | \n", "29239.0 | \n", "
3 | \n", "2.0 | \n", "1.0 | \n", "37.0 | \n", "46990.0 | \n", "
4 | \n", "2.0 | \n", "1.0 | \n", "57.0 | \n", "8617.0 | \n", "