1. 程式人生 > >Tensorflow:TypeError: pred must not be a Python bool

Tensorflow:TypeError: pred must not be a Python bool

這個問題常見且不小心就會遇到,記錄下O(∩_∩)O哈!

[email protected]:~/Documents/code/pointnet/models$ python pointnet_SE.py
('input_image', <tf.Tensor 'ExpandDims:0' shape=(32, 1024, 3, 1) dtype=float32>)
Traceback (most recent call last):
  File "pointnet_SE.py", line 138, in <module>
    net, end_points = get_model(inputs, True)
  File "pointnet_SE.py", line 37, in get_model
    transform = input_transform_net(net, is_training, bn_decay, K=3)
  File "/home/frr/Documents/code/pointnet/models/transform_nets.py", line 29, in input_transform_net
    scope='tconv1', bn_decay=bn_decay)
  File "/home/frr/Documents/code/pointnet/models/../utils/tf_util.py", line 167, in conv2d
    bn_decay=bn_decay, scope='bn')
  File "/home/frr/Documents/code/pointnet/models/../utils/tf_util.py", line 536, in batch_norm_for_conv2d
    return batch_norm_template(inputs, is_training, scope, [0, 1, 2], bn_decay)
  File "/home/frr/Documents/code/pointnet/models/../utils/tf_util.py", line 482, in batch_norm_template
    lambda: tf.no_op())
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/util/deprecation.py", line 289, in new_func
    return func(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/control_flow_ops.py", line 1802, in cond
    raise TypeError("pred must not be a Python bool")
TypeError: pred must not be a Python bool

貼出一段先嚇一下小夥伴們,有些小夥伴可能剛接觸程式碼沒有很久,碰到error就會非常煩躁,甚至直接就give up了,但是作為祖國花朵的我們怎麼能說放棄就放棄呢?其實看著這段報錯很嚇人,有用的只有最後一行!!

TypeError: pred must not be a Python bool

其實就是個型別錯誤,或者不相容的問題,
LZ直接定義is_training = True,因為定義的is_training=True不是tf.bool型別,所以導致不相容,只要定義的時候加上type就行了,舉個例子:

is_training = tf.cast(True, tf.bool)

調程式碼就還是得慢慢來,切勿心浮氣躁,小夥伴們加油!哈哈,順便祝下自己生日快樂,Felaim每天要加油,開心O(∩_∩)O~~

相關推薦

Tensorflow:TypeError: pred must not be a Python bool

這個問題常見且不小心就會遇到,記錄下O(∩_∩)O哈! [email protected]:~/Documents/code/pointnet/models$ python pointnet_SE.py ('input_image', <tf.T

HDFS ha 格式化報錯:a shared edits dir must not be specified if HA is not enabled.

錯誤內容: Formatting using clusterid: CID-19921335-620f-4e72-a056-899702613a6b 2019-01-12 07:28:46,986 INFO namenode.FSEditLog: Edit logging is async:true

Oauth2.0 整合springCloud的Zuul 解決關鍵BUG 報錯信息:Principal must not be null

get ssi tin scope persist core gin cat star 不清楚Oauth2.0 的 可以查看我前幾篇博文 Zuul 為springCloud 微服務框架 單獨可以使用 非常簡單 可以上網查證 此文只說明如何解決Oauth2.0 和Zuul 包

Windows下 Tensorflow安裝問題: Could not find a version that satisfies the requirement tensorflow

方式 find get rem fin .py AS exe ati   Tensorflow 需要 Python 3.5/3.6 64bit 版本: 具體的安裝方式可查看:https://www.tensorflow.org/install/install_windo

ClusterHostAndPorts must not be null!

使用springboot整合redis,啟動報錯,排查後發現是配置問題,配置叢集引數前先要配置叢集節點。 錯誤配置: spring.redis.host=127.0.0.1 spring.redis.port=6379 spring.redis.password=pass123

解決TensorFlow安裝問題: Could not find a version that satisfies the requirement tensorflow

環境:win7 64   Python版本:3.7.0 安裝過程中提示:Could not find a version that satisfies the requirement tensorflow,很是鬱悶啊,最後度娘了一下知道了就是因為Python版本的問題啊Tensor

ViewHolder views must not be attached when created. Ensure that you are not passing 'true' to the at

如果在使用Recyclerview的時候出現下面的異常 ViewHolder views must not be attached when created. Ensure that you are not passing ‘true’ to the attachToRoot par

解決辦法:error: inner element must either be a resource reference or empty.

  今天在linux上編譯程式碼,結果出錯了: error: <item> inner element must either be a resource reference or empty. 看看程式碼: <array name="network">

TypeError: ufunc did not contain a loop with signature matching types dtype('U32')

原因:object型別和int型別相加減 解決方法: 此時的object型別可能是‘12.3’這樣str格式的數字,如果要運算必須進行格式轉換:  可採用如下方法(pd.to_numeric()): panel_info['input'] = pd.to_numeric(pan

Django--bug--ImproperlyConfigured: The SECRET_KEY setting must not be empty.

Django配置Restframework後,建立使用者模型,執行遷移的時候報如下錯誤: django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be empty. 錯誤原因: manage.py中米有se

java.lang.IllegalArgumentException: The given id must not be null!

java.lang.IllegalArgumentException: The given id must not be null! 嚴重: Servlet.service() for servlet [dispatcher] in context with path [/sxnd-e

Kotlin中Fragment 控制元件初始化報錯 XXX must not be null

Android Extensions在Fragment中遇到的問題 在Fragment中使用Android Extensions來查詢使用控制元件的時候遇到該控制元件為空的異常: java.lang.IllegalStateException: rcvOrders must not b

SpringMVC報錯:The given id must not be null

普通看這個錯誤肯定是入參id為空了, 但是有一種情況是你入參沒有id這個引數, 系統還是報這個錯誤, 比如如下程式碼 @RequestMapping( value = "/messages/{userId}",

querydsl中使用predicate報錯:java.lang.IllegalArgumentException: Predicate must not be null!

如題,在使用querydsl結合mongo-jpa查詢時,出現問題。問題是這樣的,controller層程式碼如下: @GetMapping("/pagebypredicate") public Page<UserVo> pageByPredicate(@QuerydslPred

Android&Kotlin筆記1——TextView賦值出現java.lang.IllegalStateException: tv must not be null

前言 現在有很多Android開發的小夥伴使用Kotlin開發應用了,今天小編在使用Kotlin開發的時候遇到個問題,就是在TextView賦值時候出現了java.lang.IllegalStateException: tv must not be null的錯誤,就有點糾結為什麼為

庖丁解牛 dic home should not be a file, but a directory!

最近一個專案,用到了paoding分詞器。 在開發階段我將詞庫放到了src目錄,配置檔案使用了classpath:dic,目的是為了增加可移植性。 發現問題:在啟動伺服器的時候丟擲 net.paod

匯入adt專案進入android studio報Error:(2) Error parsing XML: prefix must not be bound to one of the reserved

在匯入Adt用ant編譯的專案進入android studio後,編譯報如下錯誤: Error:(2) Error parsing XML: prefix must not be bound to one of the reserved namespace names 在彈

解決java.lang.NullPointerException: View must not be null!

昨天寫專案的時候遇到一個“老朋友”:java.lang.NullPointerException: View must not be null!仔細查看了一下程式碼,發現view並不為空啊,琢磨了好久,通過查資料才發現if判斷的時候出了紕漏,這裡先放出錯誤原碼:  case

Rabbitmq消息服務器通訊異常: name must not be blank

res tex check ive routing 遇到 expires span rabbit 前人挖坑,後人填! 倒黴的遇到一個破項目,該 項目使用了 RabbitMQ 消息隊列向服務器發送消息, 但在發送中老是報 RabbitMQ 服務器異常! 呃,查看了服務器,服務

python出現float() argument must be a string or a number, not 'map'的錯誤

報錯:TypeError: float() argument must be a string or a number, not 'map' 這時候,首先你肯定是用了map()這個函式,不管你用map這個函式把資料轉變成了什麼格式,不管是int還是float還是其它的,最後