2015-12-08 43 views
8

:Hata ben tensorflow içinde bırakma işlevselliğini kullanmaya çalışıyorum

sess=tf.InteractiveSession() 
initial = tf.truncated_normal([1,4], stddev=0.1) 
x = tf.Variable(initial) 
keep_prob = tf.placeholder("float") 
dx = tf.nn.dropout(x, keep_prob) 
sess.run(tf.initialize_all_variables()) 
sess.run(dx, feed_dict={keep_prob: 0.5}) 
sess.close() 

Bu örnek the tutorial içinde nasıl yapıldığını çok benzer; ancak, aşağıdaki hata ile sona:

RuntimeError: min: Conversion function <function constant at 0x7efcc6e1ec80> for type <type 'object'> returned incompatible dtype: requested = float32_ref, actual = float32 

Ben sorunun arka plan gibi görünüyor d_type float32_ref, anlamak için bazı sorun var. Ayrıca dtype=tf.float32 belirtmeyi denedim, ancak bu hiçbir şeyi düzeltmiyor.

RuntimeError: min: Conversion function <function constant at 0x7efcc6e1ec80> for type <type 'object'> returned incompatible dtype: requested = float64_ref, actual = float64 

Düzenleme::

yerine float32 ait float64 aynı hatayı alıyorum döküm eğer Ancak

sess=tf.Session() 
x=tf.Variable(np.array([1.0,2.0,3.0,4.0])) 
sess.run(x.initializer) 
x=tf.cast(x,tf.float32) 
prob=tf.Variable(np.array([0.5])) 
sess.run(prob.initializer) 
prob=tf.cast(prob,tf.float32) 
dx=tf.nn.dropout(x,prob) 
sess.run(dx) 
sess.close() 

:

Ben de float32 ile çalışıyor bu örnek, denenmiş

Bu sorun yalnızca doğrudan Değişken üzerinde bırakma kullanıldığında ortaya çıkıyor gibi görünüyor s, Örnek, yer tutucular ve Değişkenler ve tutucuların ürünler için çalışır:

sess=tf.InteractiveSession() 
x = tf.placeholder(tf.float64) 

sess=tf.InteractiveSession() 
initial = tf.truncated_normal([1,5], stddev=0.1,dtype=tf.float64) 
y = tf.Variable(initial) 

keep_prob = tf.placeholder(tf.float64) 
dx = tf.nn.dropout(x*y, keep_prob) 
sess.run(tf.initialize_all_variables()) 
sess.run(dx, feed_dict={x : np.array([1.0, 2.0, 3.0, 4.0, 5.0]),keep_prob: 0.5}) 
sess.close() 

cevap

7

Bu taahhüt son giderilmiştir tf.nn.dropout uygulanmasında bir hata olduğunu ve TensorFlow sonraki sürümünde yer alacaktır. Şimdilik, sorunu önlemek için ya build TensorFlow from source ya da programınızı aşağıdaki gibi değiştirin:

#dx = tf.nn.dropout(x, keep_prob) 
dx = tf.nn.dropout(tf.identity(x), keep_prob) 
İlgili konular