您当前的位置: 首页 >  tensorflow

段智华

暂无认证

  • 0浏览

    0关注

    1232博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

CS285 2019 Tensorflow Tutorial( Tips and tricks)

段智华 发布时间:2019-10-19 10:59:23 ,浏览量:0

CS285 2019 Tensorflow Tutorial( Tips and tricks) 

# -*- coding: utf-8 -*-

import os
import warnings
os.environ['TF_CPP_MIN_LOG_LEVEL']='3'
warnings.filterwarnings('ignore')

import tensorflow as tf
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.cm as cm
import matplotlib.patches as mpatches

def tf_reset():
    try:
        sess.close()
    except:
        pass
    tf.reset_default_graph()
    return tf.Session()

#(a) Check your dimensions
a = tf.constant(np.random.random((4,1)))
b = tf.constant(np.random.random((1,4)))
c=a*b
assert  c.get_shape()==(4,4) 


#(b) Check what variables have been created
sess =tf_reset()
a = tf.get_variable('I_am_a_variable',shape=[4,6])
b = tf.get_variable('I_am_a_variable_too',shape=[2,7])
for var in tf.global_variables():
    print(var.name)


# Look at the tensorflow API, or open up a python terminal a
关注
打赏
1659361485
查看更多评论
立即登录/注册

微信扫码登录

0.0572s