嗨,我在Pi 3上运行基于以上内容的ML模型时遇到困难 代码是:
import pandas as pd
import tensorflow as tf
# deep learning library. Tensors are just multi-dimensional arrays
import numpy as np
import time
import skimage
from PIL import Image
import numpy as np
import sys
import os
import csv
# Import the `transform` module from `skimage`
from skimage import transform
from skimage import data
import glob
from os import walk
fileLists = []
image28 = []
value = []
format='.jpg'
path = '/testpic'
folder = os.fsencode(path)
for root, directories, filenames in os.walk(path):
for filename in filenames:
print (os.path.join(root,filename))
if filename.endswith(('.jpg', '.png', '.gif')):
fileLists.append(skimage.data.imread(os.path.join(root,filename)))
time1 = time.time()
images28 = [transform.resize(fileList, (227, 227)) for fileList in
fileLists]
train_x = np.array(images28)
new_model = tf.keras.models.load_model('ml.h5')
predictions = new_model.predict(train_x)
for i in range(10):
time1 = time.time()
print(np.argmax(predictions[i]))
time2 = time.time()
print((time2-time1))
运行它时,出现以下错误:
使用TensorFlow后端。 2018-11-02 09:43:34.904211:I tensorflow / core / grappler / optimizers / meta_optimizer.cc:344]开始针对抓钩项目进行优化:tf_graph 2018-11-02 09:43:34.937663:我tensorflow / core / grappler / optimizers / meta_optimizer.cc:344]开始对grappler项目进行优化:tf_graph 2018-11-02 09:43:42.740079:I tensorflow / core / grappler / optimizers / meta_optimizer.cc:344]开始针对抓钩项目进行优化:tf_graph 2018-11-02 09:43:43.125458:I tensorflow / core / grappler / optimizers / meta_optimizer.cc:344]开始针对抓钩项目进行优化:tf_graph 2018-11-02 09:43:43.720775:W tensorflow / core / framework / allocator.cc:122] 67108864的分配超过了系统内存的10%。 2018-11-02 09:43:44.152943:W tensorflow / core / framework / allocator.cc:122] 67108864的分配超过了系统内存的10%。 2018-11-02 09:43:44.298756:W tensorflow / core / framework / allocator.cc:122] 67108864的分配超过了系统内存的10%。 2018-11-02 09:43:44.299426:I tensorflow / core / grappler / optimizers / meta_optimizer.cc:344]开始针对抓钩项目进行优化:tf_graph 2018-11-02 09:44:08.801283:I tensorflow / core / grappler / optimizers / meta_optimizer.cc:344]开始针对抓钩项目进行优化:tf_graph 2018-11-02 09:44:09.582225:I tensorflow / core / grappler / optimizers / meta_optimizer.cc:344]开始针对抓钩项目进行优化:tf_graph 2018-11-02 09:44:09.788274:W tensorflow / core / framework / allocator.cc:122] 67108864的分配超过了系统内存的10%。 2018-11-02 09:44:10.183454:W tensorflow / core / framework / allocator.cc:122] 67108864的分配超过了系统内存的10%。 2018-11-02 09:44:28.074020:我tensorflow / core / grappler / optimizers / meta_optimizer.cc:344]开始对抓钩项进行优化:tf_graph
之后程序被杀死。
在培训过程中,我已将批次大小更改为1,但是没有任何固定内容。
请帮助。