0%
config
1 2 3
| tfconfig = tf.ConfigProto(allow_soft_placement=True) tfconfig.gpu_options.allow_growth=True sess = tf.Session(config=tfconfig)
|
声明placeholder
1
| self._image = tf.placeholder(tf.float32, shape=[1, None, None, 3])
|
数字转换
1 2 3
| tf.to_int32() tf.ceil() np.float32()
|
数组操作
1 2
| tf.transpose() tf.reshape()
|
py_func
1 2 3 4 5 6 7
| py_func( func, inp, Tout, stateful=True, name=None )
|
时间
loss 常用函数
1 2 3
| cross_entropy = -tf.reduce_sum(true_y*tf.log(out_y)) correct_prediction = tf.equal(tf.argmax(out_y,1), tf.argmax(true_y,1)) accuracy = tf.reduce_mean(tf.cast(correct_prediction, "float"))
|