[英]How to change Keras/tensorflow version in Google colab?
[英]google colab tensorflow keras model ran yesterday perfectly but failing today
我非常驚訝。 同樣的程序一切都很完美。 今天剛睡,打開google colab運行程序。 這是我的第一個深度學習項目。 昨天運行完美。 但是當我今天運行時,它給出了一個奇怪的錯誤。 需要幫忙。 為什么會出現這樣的錯誤? 如何解決? 谷歌colab截圖:
代碼:
#Step3: test_img_path: Location of the image we want the model to predict
test_img = image.load_img(test_img_path,target_size=(224,224))
#Step4: Deep learning models expect a batch of images represented by array
# At this stage we will have a processed image of size 224x224x3.
# Convert it to a batch of images denoted by nx224x224x3 where n denotes total images
# In this case, n=1
test_img_array = image.img_to_array(test_img)
# Convert the array to a batch
test_img_batch = np.expand_dims(test_img_array,axis=0)
#Step5: At the data level, an original image data is stored in the in terms of the pixels.
# Now, normalizing the image
nor_testimg = preprocess_input(test_img_batch)
#Step6: Import the model and input our test image
# Model here means, it is already trained by someone else and I don't have to do it again
# Moreover, they made their hardwork or trained model freely available to every on on the keras, we just download it
model = tf.keras.applications.resnet50.ResNet50()
#Step7: Lets see how and what the model would predict
predict_testimg = model.predict(nor_testimg)
# Decode the predictions
print(decode_predictions(predict_testimg,top=3)[0])
在上面的代碼中, tf.keras.applications.re.net50.ResNet50()
是導致我今天運行時出現問題的代碼。 同樣的程序昨天運行成功。 現在,如果我刪除結束括號tf.keras.applications.re.net50.ResNet50
,它運行完美但在代碼的下一行中引發錯誤。
問題不在於你,它在於 Keras,因為它試圖用 utf 8 解碼字符串。如果我能得到它的更多部分,那么它可能會有所幫助
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.