nlp的基础知识学习
1.tensorflow 基础知识
1.1 tensorflow的安装
由于我的电脑不支持gpu加速,所以安装的是cpu 版本,使用pip install tensorflow的命令
1.2 tensorflow的知识点
创建常量及变量
import tensorflow as tf
# 创建常量
data1 = tf.constant(2, dtype=tf.int32)
# 创建变量
data2 = tf.Variable(10, name='var')
tensorflow本质
将numpy转化为tensor的格式
a = np.zeros((3, 3))
ta = tf.convert_to_tensor(a)
with tf.Session() as sess:
print(sess.run(ta))
placeholder(先占位再传数)
tensorflow中又一保存数据的利器,placeholder(type,strucuct…)它的第一个参数是你要保存的数据的数据类型,大多数是tensorflow中的float3