AttributeError: module 'tensorflow' has no attribute 'select'
2017-12-22 16:57
661 查看
# p79自定义损失函数import tensorflow as tffrom numpy.random import RandomStatebatch_size = 8x = tf.placeholder(tf.float32, shape = (None,2),name = 'x-input')y_ = tf.placeholder(tf.float32, shape = (None,1),name = 'y-input')w1 = tf.Variable(tf.random_normal([2,1],stddev = 1,seed = 1))y = tf.matmul(x,w1)loss_less = 10loss_more = 1loss = tf.reduce_sum(tf.select(tf.greater(y_,y), (y-y_) * loss_more, (y_-y) * loss_less))train_step = tf.train_AdamOptimizer(0.001).minimize(loss)rdm = RandomState(1)dataset_size = 128X = rdm.rand(dataset_size,2)Y = [[x1+x2+rdm.rand()/10.0-0.05] for (x1,x2) in X]with tf.Session() as sess: init_op = tf.initialize_all_variables() sess.run(init_op) STEP = 5000 for i in range(STEP): start = (i * batch_size) % dataset_size end = min(start+batch_size, dataset_size) sess.run(train_step, feed_dict = {x:X[start:end], y:Y[start:end]}) print(sess.run(w1))AttributeError: module 'tensorflow' has no attribute 'select'tf.select ——>tf.where
相关文章推荐
- AttributeError: module 'tensorflow' has no attribute 'select'
- AttributeError: module 'tensorflow' has no attribute 'global_variables_initializer'解决
- 【TensorFlow问题】AttributeError:'module' object has no attribute 'mul'
- 4000 AttributeError: module 'select' has no attribute 'error'解决方法
- TF版本问题:解决AttributeError: module 'tensorflow' has no attribute 'mul'—Jason niu
- AttributeError: module 'tensorflow' has no attribute 'sub'
- 【tensorflow_error】'module' has no attribute 'select'
- 【TensorFlow问题】AttributeError:'module' object has no attribute 'mul'
- 【TensorFlow问题】AttributeError:'module' object has no attribute 'mul'
- AttributeError: module 'tensorflow' has no attribute 'pack'
- AttributeError: module 'tensorflow' has no attribute 'mul'
- Tensorflow出现AttributeError: module 'tensorflow' has no attribute 'constant'问题怎么办?
- 使用旧版本tensorflow出现了negative等报错的问题,AttributeError: 'module' object has no attribute 'xxx'"
- 【tensorflow_error】'module' has no attribute 'select'
- Tensorflow:Attribute Error: 'module' object has no attribute 'mul'
- AttributeError: 'module' object has no attribute 'text_format'
- 问题:‘tensorflow’ has no attribute 'select'
- AttributeError: module 'os' has no attribute 'mknod'
- AttributeError: module 'cv2' has no attribute 'CV_HAAR_SCALE_IMAGE'
- AttributeError: 'module' object has no attribute 'text_format'