- 博客(6)
- 收藏
- 关注
原创 x[0],x[1],x[:,1],x[2,:] 区别
x =[[1,2,3], [2,4,5], [3,4,2]]#不使用numpy转化为标准数组,列表不能使用[:,2]等x=np.array(x)print(x[0])print(x[1])print(x[:,1])print(x[2,:])结果D:\ProgramFiles\anaconda3\python.exe D:/Python/DeepLearning/test1.py[1 2 3][2 4 5][2 4 4][3 4 2]Process f.
2022-02-19 11:00:29 1714
原创 关于tensorflow2.0的tf.Session() as sess的说明
import tensorflow.compat.v1 as tf#import tensorflow as tftf.disable_eager_execution()#2.0版本与1.0版本不兼容,使用2.0版本时应使用上面的程序完成从1.x到2.x的迁移a = tf.constant(4)b = tf.constant(7)c = a*bsess = tf.compat.v1.Session()#使用1.0的迁移print(sess.run(c))sess.close()#2.
2022-01-27 12:45:43 4220 1
原创 one_hot函数
import numpy as npimport tensorflow as tfindices = [0, 1, 1] # rank=1depth = 8a = tf.one_hot(indices, depth) # rank=2,输出为[3,3]indices=[0,2,-2,1] #rank=1depth=7b=tf.one_hot(indices,depth,on_value=5.0,off_value=1.0,axis=-1)print(a)print(b).
2022-01-26 23:28:36 1861
原创 dtype 和 shape
import tensorflow as tfimport numpy as npa =np.array([[[4,2],[3,4],[5,6]],[[2,1],[3,4],[4,5]]])print(a.dtype)print(a.shape)结果:2022-01-25 14:35:04.044154: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic libr.
2022-01-25 15:12:43 1466
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人