第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

python中的模型訓(xùn)練和Golang中的模型運(yùn)行,模型導(dǎo)入過(guò)程中的問(wèn)題

python中的模型訓(xùn)練和Golang中的模型運(yùn)行,模型導(dǎo)入過(guò)程中的問(wèn)題

Go
蝴蝶不菲 2022-06-27 17:32:05
我安裝了 TensorFlow (2.3) 的最新版本,在 Python 下運(yùn)行良好,但在 Golang 下卻出現(xiàn)異常:...但不包含包 github.com/tensorflow/tensorflow/tensorflow/go/core/protobuf/for_core_protos_go_proto通過(guò)將版本更改為 1.15.0,我讓 TensorFlow 與 Golang 一起使用現(xiàn)在,我面臨以下問(wèn)題:使用 TensorFlow 2.3 的 Python 代碼import tensorflow as tf    df = pd.read_csv(data_path, sep=';')X = df[df.columns[:8]]y = df[df.columns[8:-1]]X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.3)    model = tf.keras.Sequential()model.add(tf.keras.layers.Dense(8, activation='relu', name="inputNode"))model.add(tf.keras.layers.Dense(150, activation='relu'))model.add(tf.keras.layers.Dense(3, name="inferNode"))model.compile(loss='mean_squared_error', optimizer='adam', metrics=['accuracy'])model.fit(X_train, y_train, epochs=500)    tf.keras.models.save_model(model=model, filepath='./', save_format='tf')使用 TensorFlow 1.15.0 的 Golang 代碼model, err := tf.LoadSavedModel("./", []string{"serve"}, nil)if err != nil {    fmt.Printf("Error loading saved model: %s\n", err.Error())    return}defer model.Session.Close()data := [][]float32{make([]float32, 8)}data[0][0] = 1.0data[0][1] = 1.0data[0][2] = 1.0data[0][3] = 1.0data[0][4] = 1.0data[0][5] = 1.0data[0][6] = 1.0data[0][7] = 1.0tensor, _ := tf.NewTensor(data)   result, err := model.Session.Run(    map[tf.Output]*tf.Tensor{        model.Graph.Operation("inputNode_input").Output(0): tensor, // Replace this with your input layer name    },    []tf.Output{        model.Graph.Operation("inferNode").Output(0), // Replace this with your output layer name    },    nil,)    if err != nil {    fmt.Printf("Error running the session with input, err: %s\n", err.Error())    return}    fmt.Printf("Result value: %v \n", result[0].Value())golang 拋出這個(gè)異常:-- FAIL: TestMlPredict (6.93s)panic: nil-Operation. If the Output was created with a Scope object, see Scope.Err() for details. [recovered]    panic: nil-Operation. If the Output was created with a Scope object, see Scope.Err() for details.
查看完整描述

2 回答

?
烙印99

TA貢獻(xiàn)1829條經(jīng)驗(yàn) 獲得超13個(gè)贊

實(shí)際上,我在我維護(hù)的 TensorFlow 的一個(gè)分支中修復(fù)了第一個(gè)問(wèn)題,其中包含所有已編譯的 protobuf。fork 是包的依賴項(xiàng)galeone/tfgo,它使用go mod.

你試試

go get github.com/galeone/tfgo

您將能夠使用 tensorflow/go 和 tensorflow/op 包 + tfgo 的所有附加功能。


查看完整回答
反對(duì) 回復(fù) 2022-06-27
?
繁花不似錦

TA貢獻(xiàn)1851條經(jīng)驗(yàn) 獲得超4個(gè)贊

操作名稱錯(cuò)誤。我做了什么來(lái)找出這些名字?我執(zhí)行了cli命令: saved_model_cli show --dir ./ --all

那么 golang 和 tensorflow 2.3 呢?請(qǐng)檢查問(wèn)題:github問(wèn)題 和自述文件:自述文件


查看完整回答
反對(duì) 回復(fù) 2022-06-27
  • 2 回答
  • 0 關(guān)注
  • 352 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)