在keras.sequential中获得很多警告和错误

如何解决在keras.sequential中获得很多警告和错误

我曾经使用以下功能,但是现在运行它时,升级到Tensorflow 2.3后,我收到许多警告和dtypes令人困惑的通知。我不确定如何修复功能以正确运行keras顺序代码以生成正确的预测。

这是我的实现方式

feature_columns = []

for col in numericColumns:
  col = feature_column.numeric_column(col)
  feature_columns.append(col)

for col in categoricalColumns:
  col = feature_column.indicator_column(feature_column.categorical_column_with_vocabulary_list(col,df_train[col].unique()))
  feature_columns.append(col)

feature_layer = tf.keras.layers.DenseFeatures(feature_columns)


from tensorflow.keras import optimizers

def build_model():
  
  model = keras.Sequential([
    feature_layer,layers.Dense(10,activation='relu'),layers.Dense(1)
  ])

  optimizer = tf.optimizers.RMSprop(learning_rate=lr_schedule)
  model.compile(loss='mse',optimizer=optimizer,metrics=['mse'])
  return model

model = build_model()

这是我调用该函数的方式:

# train the model
history = model.fit(train_ds,validation_data=val_ds,epochs=30)

这是我得到的杂乱的回报,我正在寻找帮助以弄清楚如何修复或重写:

Epoch 1/30
WARNING:tensorflow:Layers in a Sequential model should only have a single input tensor,but we receive a <class 'dict'> input: {'MSSubClass': <tf.Tensor 'ExpandDims_49:0' shape=(None,1) dtype=float64>,'MSZoning': <tf.Tensor 'ExpandDims_50:0' shape=(None,1) dtype=int32>,'LotFrontage': <tf.Tensor 'ExpandDims_46:0' shape=(None,'LotArea': <tf.Tensor 'ExpandDims_44:0' shape=(None,'Street': <tf.Tensor 'ExpandDims_66:0' shape=(None,'LotShape': <tf.Tensor 'ExpandDims_47:0' shape=(None,'LandContour': <tf.Tensor 'ExpandDims_42:0' shape=(None,'Utilities': <tf.Tensor 'ExpandDims_69:0' shape=(None,'LotConfig': <tf.Tensor 'ExpandDims_45:0' shape=(None,'LandSlope': <tf.Tensor 'ExpandDims_43:0' shape=(None,'Neighborhood': <tf.Tensor 'ExpandDims_55:0' shape=(None,'Condition1': <tf.Tensor 'ExpandDims_16:0' shape=(None,'Condition2': <tf.Tensor 'ExpandDims_17:0' shape=(None,'BldgType': <tf.Tensor 'ExpandDims_4:0' shape=(None,'HouseStyle': <tf.Tensor 'ExpandDims_39:0' shape=(None,'OverallQual': <tf.Tensor 'ExpandDims_58:0' shape=(None,'OverallCond': <tf.Tensor 'ExpandDims_57:0' shape=(None,'YearBuilt': <tf.Tensor 'ExpandDims_71:0' shape=(None,'YearRemodAdd': <tf.Tensor 'ExpandDims_72:0' shape=(None,'RoofStyle': <tf.Tensor 'ExpandDims_62:0' shape=(None,'RoofMatl': <tf.Tensor 'ExpandDims_61:0' shape=(None,'Exterior1st': <tf.Tensor 'ExpandDims_22:0' shape=(None,'Exterior2nd': <tf.Tensor 'ExpandDims_23:0' shape=(None,'MasVnrType': <tf.Tensor 'ExpandDims_52:0' shape=(None,'MasVnrArea': <tf.Tensor 'ExpandDims_51:0' shape=(None,'ExterQual': <tf.Tensor 'ExpandDims_21:0' shape=(None,'ExterCond': <tf.Tensor 'ExpandDims_20:0' shape=(None,'Foundation': <tf.Tensor 'ExpandDims_25:0' shape=(None,'BsmtQual': <tf.Tensor 'ExpandDims_13:0' shape=(None,'BsmtCond': <tf.Tensor 'ExpandDims_5:0' shape=(None,1) dtype=int64>,'BsmtExposure': <tf.Tensor 'ExpandDims_6:0' shape=(None,'BsmtFinType1': <tf.Tensor 'ExpandDims_9:0' shape=(None,'BsmtFinSF1': <tf.Tensor 'ExpandDims_7:0' shape=(None,'BsmtFinType2': <tf.Tensor 'ExpandDims_10:0' shape=(None,'BsmtFinSF2': <tf.Tensor 'ExpandDims_8:0' shape=(None,'BsmtUnfSF': <tf.Tensor 'ExpandDims_14:0' shape=(None,'TotalBsmtSF': <tf.Tensor 'ExpandDims_68:0' shape=(None,'Heating': <tf.Tensor 'ExpandDims_37:0' shape=(None,'HeatingQC': <tf.Tensor 'ExpandDims_38:0' shape=(None,'CentralAir': <tf.Tensor 'ExpandDims_15:0' shape=(None,'Electrical': <tf.Tensor 'ExpandDims_18:0' shape=(None,'1stFlrSF': <tf.Tensor 'ExpandDims:0' shape=(None,'2ndFlrSF': <tf.Tensor 'ExpandDims_1:0' shape=(None,'LowQualFinSF': <tf.Tensor 'ExpandDims_48:0' shape=(None,'GrLivArea': <tf.Tensor 'ExpandDims_35:0' shape=(None,'BsmtFullBath': <tf.Tensor 'ExpandDims_11:0' shape=(None,'BsmtHalfBath': <tf.Tensor 'ExpandDims_12:0' shape=(None,'FullBath': <tf.Tensor 'ExpandDims_26:0' shape=(None,'HalfBath': <tf.Tensor 'ExpandDims_36:0' shape=(None,'BedroomAbvGr': <tf.Tensor 'ExpandDims_3:0' shape=(None,'KitchenAbvGr': <tf.Tensor 'ExpandDims_40:0' shape=(None,'KitchenQual': <tf.Tensor 'ExpandDims_41:0' shape=(None,'TotRmsAbvGrd': <tf.Tensor 'ExpandDims_67:0' shape=(None,'Functional': <tf.Tensor 'ExpandDims_27:0' shape=(None,'Fireplaces': <tf.Tensor 'ExpandDims_24:0' shape=(None,'GarageType': <tf.Tensor 'ExpandDims_33:0' shape=(None,'GarageYrBlt': <tf.Tensor 'ExpandDims_34:0' shape=(None,'GarageFinish': <tf.Tensor 'ExpandDims_31:0' shape=(None,'GarageCars': <tf.Tensor 'ExpandDims_29:0' shape=(None,'GarageArea': <tf.Tensor 'ExpandDims_28:0' shape=(None,'GarageQual': <tf.Tensor 'ExpandDims_32:0' shape=(None,'GarageCond': <tf.Tensor 'ExpandDims_30:0' shape=(None,'PavedDrive': <tf.Tensor 'ExpandDims_59:0' shape=(None,'WoodDeckSF': <tf.Tensor 'ExpandDims_70:0' shape=(None,'OpenPorchSF': <tf.Tensor 'ExpandDims_56:0' shape=(None,'EnclosedPorch': <tf.Tensor 'ExpandDims_19:0' shape=(None,'3SsnPorch': <tf.Tensor 'ExpandDims_2:0' shape=(None,'ScreenPorch': <tf.Tensor 'ExpandDims_65:0' shape=(None,'PoolArea': <tf.Tensor 'ExpandDims_60:0' shape=(None,'MiscVal': <tf.Tensor 'ExpandDims_53:0' shape=(None,'MoSold': <tf.Tensor 'ExpandDims_54:0' shape=(None,'YrSold': <tf.Tensor 'ExpandDims_73:0' shape=(None,'SaleType': <tf.Tensor 'ExpandDims_64:0' shape=(None,'SaleCondition': <tf.Tensor 'ExpandDims_63:0' shape=(None,1) dtype=int32>}
Consider rewriting this model with the Functional API.
WARNING:tensorflow:Layers in a Sequential model should only have a single input tensor,1) dtype=int32>}
Consider rewriting this model with the Functional API.
35/37 [===========================>..] - ETA: 0s - loss: 120.7742 - mse: 120.7742WARNING:tensorflow:Layers in a Sequential model should only have a single input tensor,1) dtype=int32>}
Consider rewriting this model with the Functional API.

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

相关推荐


使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams[&#39;font.sans-serif&#39;] = [&#39;SimHei&#39;] # 能正确显示负号 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 -&gt; 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(&quot;/hires&quot;) 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&lt;String
使用vite构建项目报错 C:\Users\ychen\work&gt;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)&gt; insert overwrite table dwd_trade_cart_add_inc &gt; select data.id, &gt; data.user_id, &gt; data.course_id, &gt; date_format(
错误1 hive (edu)&gt; insert into huanhuan values(1,&#39;haoge&#39;); 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&gt; 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 # 添加如下 &lt;configuration&gt; &lt;property&gt; &lt;name&gt;yarn.nodemanager.res