“您的输入数据用完”总是在第 # 次时代

如何解决“您的输入数据用完”总是在第 # 次时代

我一直在尝试使用 Keras 为 model.fit() 制作我的第一个数据生成器。我试图制作的数据集有两个输入,一个图像和一个浮点值。我所有的图像名称和值都存储在一个 csv 文件中。我相信我错误地制作了我的生成器,因为无论我的批量大小是多少,我总是在与我的时代相同的步骤中收到错误“您的输入用完了数据”。因此,如果我的 epochs 设置为 100,我的模型将运行到第 100 步。我的数据集大约有 100000 个图像/值。如果有人能帮我找到一个很好的解决方案。
我目前正在使用:
蟒蛇 3.8
TF-GPU 2.4.0rc1
keras 2.4.3
熊猫 1.1.4

代码:

IMG_SIZE = 400
Version = 1
batch_size = 64
val = .05

val_aug = ImageDataGenerator(rescale=1/255)
aug = ImageDataGenerator(
        rescale=1/255,rotation_range=30,width_shift_range=0.1,height_shift_range=0.1,shear_range=0.2,zoom_range=0.2,channel_shift_range=25,horizontal_flip=True,fill_mode='constant')


df = pd.read_csv('F:/DATA/Vote/Vote_Age.csv')

df = df.sample(frac = 1)
cut = int(len(df) * val)

train_df = df[cut:]
val_df = df[0:cut]
print(f'Training dataset: {len(train_df)}')
print(f'Val dataset: {len(val_df)}')

train_steps = int(len(train_df) / batch_size)
val_steps = int(len(val_df) / batch_size)

def data(df,generator,batch_size,IMG_SIZE):
        z = 0
        while True:
                df = df.sample(frac = 1)
                for i in range(int(len(df) / batch_size)):
                        images,ages,votes = [],[],[]
                        for x in range(batch_size):
                                csv_row = df.iloc[(z),:]
                                z += 1
                                image_path = f'F:/DATA/Vote/Images/{int(csv_row[0])}.jpg'
                                image = cv2.resize(cv2.imread(image_path),(int(IMG_SIZE),int(IMG_SIZE)))
                                image = cv2.cvtColor(image,cv2.COLOR_BGR2RGB)
                                image = image.reshape(-1,IMG_SIZE,3)
                                generator.fit(image)
                                image = generator.flow(image,batch_size=1)
                                image = image.next()
                                image = image.reshape(IMG_SIZE,3)

                                images.append(image)
                                ages.append(csv_row[1])
                                votes.append(int(csv_row[2]))

                        images = np.array(images)
                        ages = np.array(ages)
                        votes = np.array(votes)
                
                        return [[images,ages],[votes]]

#########
#Model was very big and unnecessary to include
#########

train_dataset = train_data(train_df,IMG_SIZE)
val_dataset = val_data(val_df,IMG_SIZE)

model.fit(
    x = train_dataset[0],y = train_dataset[1],validation_data=(val_dataset[0],val_dataset[1]),steps_per_epoch=train_steps,validation_steps=val_steps,callbacks=earlyStop,epochs=100,batch_size=batch_size,workers=multiprocessing.cpu_count(),verbose=1)

model.save(f'F:/DATA/Vote/Models/YiffModel{Version}')

输出:

...
  83/1484 [>.............................] - ETA: 4:46 - loss: 7578.7731
  84/1484 [>.............................] - ETA: 4:46 - loss: 7575.5172
  85/1484 [>.............................] - ETA: 4:46 - loss: 7572.2818
  86/1484 [>.............................] - ETA: 4:46 - loss: 7569.0662
  87/1484 [>.............................] - ETA: 4:46 - loss: 7565.8702
  88/1484 [>.............................] - ETA: 4:45 - loss: 7562.6932
  89/1484 [>.............................] - ETA: 4:45 - loss: 7559.5349
  90/1484 [>.............................] - ETA: 4:45 - loss: 7556.3948
  91/1484 [>.............................] - ETA: 4:45 - loss: 7553.2726
  92/1484 [>.............................] - ETA: 4:44 - loss: 7550.1679
  93/1484 [>.............................] - ETA: 4:44 - loss: 7547.0802
  94/1484 [>.............................] - ETA: 4:44 - loss: 7544.0094
  95/1484 [>.............................] - ETA: 4:44 - loss: 7540.9549
  96/1484 [>.............................] - ETA: 4:43 - loss: 7537.9164
  97/1484 [>.............................] - ETA: 4:43 - loss: 7534.8937
  98/1484 [>.............................] - ETA: 4:43 - loss: 7531.8863
  99/1484 [=>............................] - ETA: 4:43 - loss: 7528.8939
 100/1484 [=>............................] - ETA: 4:43 - loss: 7525.9163
WARNING:tensorflow:Your input ran out of data; interrupting training. Make sure that your dataset or generator can generate at least `steps_per_epoch * epochs` batches (in this case,148400 batches). You may need to use the repeat() function when building your dataset.
WARNING:tensorflow:Your input ran out of data; interrupting training. Make sure that your dataset or generator can generate at least `steps_per_epoch * epochs` batches (in this case,78 batches). You may need to use the repeat() function when building your dataset.

1484/1484 [==============================] - 30s 15ms/step - loss: 7250.9988 - val_loss: 13595.9355
C:\Users\Tristan\anaconda3\envs\tf2\lib\site-packages\tensorflow\python\keras\engine\training.py:2325: UserWarning: `Model.state_updates` will be removed in a future version. This property should not be used in TensorFlow 2.0,as `updates` are applied automatically.
  warnings.warn('`Model.state_updates` will be removed in a future version. '
2021-01-05 15:37:04.425018: W tensorflow/python/util/util.cc:348] Sets are not currently considered sequences,but this may change in the future,so consider avoiding using them.
C:\Users\Tristan\anaconda3\envs\tf2\lib\site-packages\tensorflow\python\keras\engine\base_layer.py:1402: UserWarning: `layer.updates` will be removed in a future version. This property should not be used in TensorFlow 2.0,as `updates` are applied automatically.
  warnings.warn('`layer.updates` will be removed in a future version. '
WARNING:tensorflow:FOR KERAS USERS: The object that you are saving contains one or more Keras models or layers. If you are loading the SavedModel with `tf.keras.models.load_model`,continue reading (otherwise,you may ignore the following instructions). Please change your code to save with `tf.keras.models.save_model` or `model.save`,and confirm that the file "keras.metadata" exists in the export directory. In the future,Keras will only load the SavedModels that have this file. In other words,`tf.saved_model.save` will no longer write SavedModels that can be recovered as Keras models (this will apply in TF 2.5).

FOR DEVS: If you are overwriting _tracking_metadata in your class,this property has been used to save metadata in the SavedModel. The metadta field will be deprecated soon,so please move the metadata to a different file.
libpng warning: iCCP: known incorrect sRGB profile

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams['font.sans-serif'] = ['SimHei'] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -> systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping("/hires") public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate<String
使用vite构建项目报错 C:\Users\ychen\work>npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-
参考1 参考2 解决方案 # 点击安装源 协议选择 http:// 路径填写 mirrors.aliyun.com/centos/8.3.2011/BaseOS/x86_64/os URL类型 软件库URL 其他路径 # 版本 7 mirrors.aliyun.com/centos/7/os/x86
报错1 [root@slave1 data_mocker]# kafka-console-consumer.sh --bootstrap-server slave1:9092 --topic topic_db [2023-12-19 18:31:12,770] WARN [Consumer clie
错误1 # 重写数据 hive (edu)> insert overwrite table dwd_trade_cart_add_inc > select data.id, > data.user_id, > data.course_id, > date_format(
错误1 hive (edu)> insert into huanhuan values(1,'haoge'); Query ID = root_20240110071417_fe1517ad-3607-41f4-bdcf-d00b98ac443e Total jobs = 1
报错1:执行到如下就不执行了,没有显示Successfully registered new MBean. [root@slave1 bin]# /usr/local/software/flume-1.9.0/bin/flume-ng agent -n a1 -c /usr/local/softwa
虚拟及没有启动任何服务器查看jps会显示jps,如果没有显示任何东西 [root@slave2 ~]# jps 9647 Jps 解决方案 # 进入/tmp查看 [root@slave1 dfs]# cd /tmp [root@slave1 tmp]# ll 总用量 48 drwxr-xr-x. 2
报错1 hive> show databases; OK Failed with exception java.io.IOException:java.lang.RuntimeException: Error in configuring object Time taken: 0.474 se
报错1 [root@localhost ~]# vim -bash: vim: 未找到命令 安装vim yum -y install vim* # 查看是否安装成功 [root@hadoop01 hadoop]# rpm -qa |grep vim vim-X11-7.4.629-8.el7_9.x
修改hadoop配置 vi /usr/local/software/hadoop-2.9.2/etc/hadoop/yarn-site.xml # 添加如下 <configuration> <property> <name>yarn.nodemanager.res