tensorflow constant placeholder feed_dictVariable
tf.constant tf.constant() 返回的 tensor 是一个常量,因为这个 tensor 的值不会变 tf.placeholder 和 feed_dict tf.placeholder 用于将普通类型,转化为 tensor 类型 feed_dict 表示投喂字典,格式为 {tensor_type: value} ,其中 tensor_type 表示 tensor 类型, value 表示对应的值,用于具体的计算 softmax_data = [ 0.7 , 0.2 , 0.1 ] one_hot_data = [ 1.0 , 0.0 , 0.0 ] # 将 float 类型转化为 tensor 类型 softmax = tf . placeholder ( tf . float32 ) one_hot = tf . placeholder ( tf . float32 ) # TODO: Print cross entropy from session # 传给 tf.multiply 的参数是两个 tensor 类型,而不是具体的值, # 具体的值在 sess.run() 时,在 feed_dict 中提供 cross_entropy = - tf . reduce_sum ( tf . multiply ( one_hot , tf . log (