yangxuntu / vrd

two models for visual relationship detection
94 stars 28 forks source link

TypeError: Using a `tf.Tensor` as a Python `bool` is not allowed. Use `if t is not None:` instead of `if t:` to test if a tensor is defined, and use TensorFlow ops such as tf.cond to execute subgraphs conditioned on the value of a tensor #2

Open GYM13 opened 6 years ago

GYM13 commented 6 years ago

I use pythoon2.7,ipython5.4,tensorflow 1.2,why ? TypeError Traceback (most recent call last) /home/gaoyouming/vtranse/train_file/train_vrd_vgg.py in () 19 20 vnet = VTranse() ---> 21 vnet.create_graph(N_each_batch, index_sp, index_cls, N_cls, N_rela) 22 23 roidb_path = cfg.DIR + 'vtranse/input/vrd_roidb.npz'

/home/gaoyouming/vtranse/net/vtranse_vgg.py in create_graph(self, N_each_batch, index_sp, index_cls, num_classes, num_predicates) 41 self.N_each_batch = N_each_batch 42 ---> 43 self.build_dete_network() 44 self.build_rd_network() 45 self.add_rd_loss()

/home/gaoyouming/vtranse/net/vtranse_vgg.py in build_dete_network(self, is_training) 50 sub_pool5 = self.crop_pool_layer(net_conv, self.sbox, "sub_pool5") 51 ob_pool5 = self.crop_pool_layer(net_conv, self.obox, "ob_pool5") ---> 52 sub_fc7 = self.head_to_tail(sub_pool5, is_training, reuse = False) 53 ob_fc7 = self.head_to_tail(ob_pool5, is_training, reuse = True) 54

/home/gaoyouming/vtranse/net/vtranse_vgg.py in head_to_tail(self, pool5, is_training, reuse) 88 pool5_flat = slim.flatten(pool5, scope='flatten') 89 fc6 = slim.fully_connected(pool5_flat, 4096, scope='fc6') ---> 90 fc6 = slim.dropout(fc6, keep_prob=self.keep_prob, is_training=True, scope='dropout6') 91 fc7 = slim.fully_connected(fc6, 4096, scope='fc7') 92 fc7 = slim.dropout(fc7, keep_prob=self.keep_prob, is_training=True, scope='dropout7')

/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/framework/python/ops/arg_scope.pyc in func_with_args(*args, *kwargs) 179 current_args = current_scope[key_func].copy() 180 current_args.update(kwargs) --> 181 return func(args, **current_args) 182 _add_op(func) 183 setattr(func_with_args, '_key_op', _key_op(func))

/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/layers/python/layers/layers.pyc in dropout(inputs, keep_prob, noise_shape, is_training, outputs_collections, scope) 1214 noise_shape=noise_shape, 1215 name=sc.name, -> 1216 _scope=sc) 1217 outputs = layer.apply(inputs, training=is_training) 1218 return utils.collect_named_outputs(

/usr/local/lib/python2.7/dist-packages/tensorflow/python/layers/core.pyc in init(self, rate, noise_shape, seed, name, kwargs) 245 kwargs): 246 super(Dropout, self).init(name=name, **kwargs) --> 247 self.rate = min(1., max(0., rate)) 248 self.noise_shape = noise_shape 249 self.seed = seed

/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.pyc in nonzero(self) 576 TypeError. 577 """ --> 578 raise TypeError("Using a tf.Tensor as a Python bool is not allowed. " 579 "Use if t is not None: instead of if t: to test if a " 580 "tensor is defined, and use TensorFlow ops such as "

TypeError: Using a tf.Tensor as a Python bool is not allowed. Use if t is not None: instead of if t: to test if a tensor is defined, and use TensorFlow ops such as tf.cond to execute subgraphs conditioned on the value of a tensor.

yangxuntu commented 6 years ago

I use tensorflow 1.4.