{"metadata":{"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"},"language_info":{"codemirror_mode":{"name":"ipython","version":3},"file_extension":".py","mimetype":"text/x-python","name":"python","nbconvert_exporter":"python","pygments_lexer":"ipython3","version":"3.6.0"}},"nbformat":4,"nbformat_minor":0,"cells":[{"metadata":{"_cell_guid":"0c32be93-9020-40c4-0cd6-514e6bbdfb1b","_active":false,"collapsed":false},"source":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load in \n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\n# Input data files are available in the \"../input/\" directory.\n# For example, running this (by clicking run or pressing Shift+Enter) will list the files in the input directory\n\nfrom subprocess import check_output\nprint(check_output([\"ls\", \"../input\"]).decode(\"utf8\"))\n\n# Any results you write to the current directory are saved as output.","execution_count":null,"cell_type":"code","outputs":[]},{"metadata":{"_cell_guid":"6d25e840-e3f0-fdbd-e8e3-0cd81349dddf","_active":false,"collapsed":false},"source":"import tensorflow as tf","execution_count":1,"cell_type":"code","outputs":[],"execution_state":"idle"},{"metadata":{"_cell_guid":"c0d0b060-e726-dbb4-95c8-9e0f2009ad2c","_active":false,"collapsed":false},"source":"# to inspect the function of variable copy\nv1 = tf.Variable(tf.random_normal([3,2]))\nv2 = tf.random_shuffle(v1)\nv3 = v1\nv4 = tf.Variable(2*v1.initialized_value())\nv_dict = {'v1':v1}\nsaver = tf.train.Saver([v1])\n\nwith tf.Session() as sess:\n    sess.run(tf.global_variables_initializer())\n    print('v1 is {}'.format(sess.run(v1)))\n    print('v2 is {}'.format(sess.run(v2)))\n    print('v4 is {}'.format(sess.run(v4)))\n    saver.save(sess,'/tmp/v.ckpy')\nwith tf.Session() as sess:\n    saver.restore(sess,'/tmp/v.ckpy')\n    print(sess.run(v1))    \n    print(sess.run(v2))\n    print('v3 is {}'.format(sess.run(v3)))\n    print(v3)\n    print(v1)\n    sess.run(v4.assign(v1))\n    print(sess.run(v4))\n    print(v1)\n    print(v4)\n    #print('v4 is {}'.format(sess.run(v4)))\n","execution_count":22,"cell_type":"code","outputs":[],"execution_state":"idle"}]}