亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

“NoneType”對象沒有屬性“raise_exception_on_not_ok_status”

“NoneType”對象沒有屬性“raise_exception_on_not_ok_status”

尚方寶劍之說 2022-06-14 15:07:33
當我定義一個函數來執行神經網絡訓練時,我得到一個錯誤。但是,當我這樣做而不使它起作用時,就沒有錯誤。為什么?def myneural():    import numpy as np    import keras    from keras import backend as K    from keras.layers import Input, Dense, Activation    from keras.models import Model, Sequential    x_train_s = np.random.randint(5, size=(20, 2))    x_test_s = x_train_s    model = Sequential([        Dense(10, input_shape=(2,)),        Activation('linear'),        Dense(2),        Activation('linear')    ])    model.compile(optimizer='adam', loss='mean_squared_error')    fittingadam = model.fit(x_train_s, x_train_s, epochs=2,                            validation_data=(x_test_s, x_test_s),                            shuffle=True, verbose=1, batch_size=None)    encoder = K.function([model.layers[0].input],                         [model.layers[1].output])    code = encoder([x_test_s])[0]myneural()我得到的錯誤是:Using TensorFlow backend.WARNING:tensorflow:From C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\framework\op_def_library.py:263: colocate_with (from tensorflow.python.framework.ops) is deprecated and will be removed in a future version.Instructions for updating:Colocations handled automatically by placer.WARNING:tensorflow:From C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\ops\math_ops.py:3066: to_int32 (from tensorflow.python.ops.math_ops) is deprecated and will be removed in a future version.Instructions for updating:Use tf.cast instead.Train on 20 samples, validate on 20 samplesEpoch 1/22019-10-03 14:34:50.275279: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX220/20 [==============================] - 0s 7ms/step - loss: 4.0432 - val_loss: 3.9670Epoch 2/2但是,當我刪除第一行和最后一行并從其他行中刪除縮進時,不會有錯誤。第一個問題:為什么會這樣?我怎樣才能解決它以運行它而沒有任何問題作為函數?第二個問題:警告呢?它們重要嗎?我怎樣才能擺脫它們?
查看完整描述

1 回答

?
一只斗牛犬

TA貢獻1784條經驗 獲得超2個贊

  • 你應該更新你的張量流。如果您已經使用最新版本(我對此表示懷疑),或者您受其他軟件包的約束,請忽略此異常。這是一個被抑制的異常,在解釋器清理期間拋出。您可以“控制”是否引發異常的事實是巧合。

  • 這些是為直接使用 tensorflow 的人準備的,所以在你的情況下是 keras。這不好,但你不能對它們做任何事情,除了檢查他們的錯誤報告者是否已經列出了這些警告。

所以一般來說:只要它做你想要exit code 0的并且最終擁有,忽略所有警告和異常。


查看完整回答
反對 回復 2022-06-14
  • 1 回答
  • 0 關注
  • 127 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號