{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": true }, "outputs": [], "source": [ "import tensorflow as tf" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": true }, "outputs": [], "source": [ "a = tf.placeholder(\"float\") # Create a symbolic variable 'a'\n", "b = tf.placeholder(\"float\") # Create a symbolic variable 'b'\n", "\n", "y = tf.multiply(a, b) # multiply the symbolic variables" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "2.000000 should equal 2.0\n", "9.000000 should equal 9.0\n" ] } ], "source": [ "with tf.Session() as sess: # create a session to evaluate the symbolic expressions\n", " print(\"%f should equal 2.0\" % sess.run(y, feed_dict={a: 1, b: 2})) # eval expressions with parameters for a and b\n", " print(\"%f should equal 9.0\" % sess.run(y, feed_dict={a: 3, b: 3}))" ] } ], "metadata": { "kernelspec": { "display_name": "Python 2", "language": "python", "name": "python2" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", "version": "2.7.6" } }, "nbformat": 4, "nbformat_minor": 1 }