C:\Users\马斌\Desktop\NGSIM_data_processing\80s\lstmtest.py:31: MatplotlibDeprecationWarning: Support for FigureCanvases without a required_interactive_framework attribute was deprecated in Matplotlib 3.6 and will be removed two minor releases later. plt.plot(history.history['loss']) C:\Users\马斌\Desktop\NGSIM_data_processing\80s\lstmtest.py:37: MatplotlibDeprecationWarning: Support for FigureCanvases without a required_interactive_framework attribute was deprecated in Matplotlib 3.6 and will be removed two minor releases later. plt.show() 20/20 [==============================] - 0s 832us/step 9/9 [==============================] - 0s 0s/step Traceback (most recent call last): File "C:\Users\马斌\Desktop\NGSIM_data_processing\80s\lstmtest.py", line 42, in <module> train_predict = scaler.inverse_transform(train_predict) File "D:\python\python3.9.5\pythonProject\venv\lib\site-packages\sklearn\preprocessing\_data.py", line 541, in inverse_transform X -= self.min_ ValueError: non-broadcastable output operand with shape (611,1) doesn't match the broadcast shape (611,2)

时间: 2023-07-25 17:03:28 浏览: 28
这个错误的原因是在进行逆变换时,输入的数组的形状与原始数据的形状不匹配。具体来说,你的 `train_predict` 数组的形状为 `(611, 1)`,而 `scaler.inverse_transform()` 函数期望的形状是 `(611, 2)`。这可能是因为你在训练模型时只使用了单个特征,但是在进行预测时却使用了多个特征。 你可以检查一下在训练模型时使用的特征数量是否与进行预测时使用的特征数量一致。如果不一致,你需要在进行预测时只使用与训练模型时相同的特征。如果特征数量相同,那么可能是在数据处理的过程中出现了错误,你需要仔细检查数据的形状和处理方法。
相关问题

C:\Users\马斌\Desktop\NGSIM_data_processing\80s\lstmtest.py:31: MatplotlibDeprecationWarning: Support for FigureCanvases without a required_interactive_framework attribute was deprecated in Matplotlib 3.6 and will be removed two minor releases later. plt.plot(history.history['loss']) C:\Users\马斌\Desktop\NGSIM_data_processing\80s\lstmtest.py:37: MatplotlibDeprecationWarning: Support for FigureCanvases without a required_interactive_framework attribute was deprecated in Matplotlib 3.6 and will be removed two minor releases later. plt.show()

这个警告是由于 Matplotlib 库版本的问题引起的。这个警告表明,您使用的 Matplotlib 版本将在未来的两个较小版本中删除支持“FigureCanvases”而不带有“required_interactive_framework”属性的功能。这可能会影响您的代码在未来的 Matplotlib 版本中的可用性。建议您更新 Matplotlib 库版本以消除这个警告。您可以通过以下命令来更新 Matplotlib 库: ``` pip install --upgrade matplotlib ``` 这将安装最新版本的 Matplotlib 库,以便您的代码能够与未来版本的 Matplotlib 兼容。

OSError: [Errno 22] Invalid argument: '"C:\\Users\\马斌\\Desktop\\NGSIM_data_processing\\NGSIM_Data.csv"'

这个错误通常是由于文件路径中的某些字符或格式不正确导致的,您可以尝试以下解决方案: 1. 检查文件路径是否正确,确保使用斜杠“/”而不是反斜杠“\”。 2. 确保文件名和扩展名正确,例如“.csv”。 3. 如果文件路径中包含空格或其他特殊字符,请使用引号将其括起来。 4. 确认文件是否存在,如果不存在,请创建一个新文件或重新下载该文件。 5. 如果您使用的是Python,尝试使用原始字符串来表示文件路径,例如 r"C:\Users\马斌\Desktop\NGSIM_data_processing\NGSIM_Data.csv"。 希望这些解决方案能够帮助您解决问题。

相关推荐

如何解决D:\python\python3.9.5\python.exe C:/Users/马斌/Desktop/NGSIM_data_processing/30s/x-y.py C:\Users\马斌\Desktop\NGSIM_data_processing\30s\x-y.py:12: MatplotlibDeprecationWarning: Support for FigureCanvases without a required_interactive_framework attribute was deprecated in Matplotlib 3.6 and will be removed two minor releases later. plt.plot(x, y) C:\Users\马斌\Desktop\NGSIM_data_processing\30s\x-y.py:20: MatplotlibDeprecationWarning: Support for FigureCanvases without a required_interactive_framework attribute was deprecated in Matplotlib 3.6 and will be removed two minor releases later. plt.show() D:\pyCharm\PyCharm 2020.2\plugins\python\helpers\pycharm_matplotlib_backend\backend_interagg.py:68: UserWarning: Glyph 36724 (\N{CJK UNIFIED IDEOGRAPH-8F74}) missing from current font. self.figure.tight_layout() D:\pyCharm\PyCharm 2020.2\plugins\python\helpers\pycharm_matplotlib_backend\backend_interagg.py:68: UserWarning: Glyph 25968 (\N{CJK UNIFIED IDEOGRAPH-6570}) missing from current font. self.figure.tight_layout() D:\pyCharm\PyCharm 2020.2\plugins\python\helpers\pycharm_matplotlib_backend\backend_interagg.py:68: UserWarning: Glyph 25454 (\N{CJK UNIFIED IDEOGRAPH-636E}) missing from current font. self.figure.tight_layout() D:\pyCharm\PyCharm 2020.2\plugins\python\helpers\pycharm_matplotlib_backend\backend_interagg.py:68: UserWarning: Glyph 20998 (\N{CJK UNIFIED IDEOGRAPH-5206}) missing from current font. self.figure.tight_layout() D:\pyCharm\PyCharm 2020.2\plugins\python\helpers\pycharm_matplotlib_backend\backend_interagg.py:68: UserWarning: Glyph 26512 (\N{CJK UNIFIED IDEOGRAPH-6790}) missing from current font. self.figure.tight_layout() D:\pyCharm\PyCharm 2020.2\plugins\python\helpers\pycharm_matplotlib_backend\backend_interagg.py:69: UserWarning: Glyph 36724 (\N{CJK UNIFIED IDEOGRAPH-8F74}) missing from current font. FigureCanvasAgg.draw(self) D:\pyCharm\PyCharm 2020.2\plugins\python\helpers\pycharm_matplotlib_backend\backend_interagg.py:69: UserWarning: Glyph 25968 (\N{CJK UNIFIED IDEOGRAPH-6570}) missing from current font. FigureCanvasAgg.draw(self) D:\pyCharm\PyCharm 2020.2\plugins\python\helpers\pycharm_matplotlib_backend\backend_interagg.py:69: UserWarning: Glyph 25454 (\N{CJK UNIFIED IDEOGRAPH-636E}) missing from current font. FigureCanvasAgg.draw(self) D:\pyCharm\PyCharm 2020.2\plugins\python\helpers\pycharm_matplotlib_backend\backend_interagg.py:69: UserWarning: Glyph 20998 (\N{CJK UNIFIED IDEOGRAPH-5206}) missing from current font. FigureCanvasAgg.draw(self) D:\pyCharm\PyCharm 2020.2\plugins\python\helpers\pycharm_matplotlib_backend\backend_interagg.py:69: UserWarning: Glyph 26512 (\N{CJK UNIFIED IDEOGRAPH-6790}) missing from current font. FigureCanvasAgg.draw(self)

D:\python\python3.9.5\python.exe C:/Users/马斌/Desktop/NGSIM_data_processing/30s/x-y.py C:\Users\马斌\Desktop\NGSIM_data_processing\30s\x-y.py:12: MatplotlibDeprecationWarning: Support for FigureCanvases without a required_interactive_framework attribute was deprecated in Matplotlib 3.6 and will be removed two minor releases later. plt.plot(x, y) C:\Users\马斌\Desktop\NGSIM_data_processing\30s\x-y.py:20: MatplotlibDeprecationWarning: Support for FigureCanvases without a required_interactive_framework attribute was deprecated in Matplotlib 3.6 and will be removed two minor releases later. plt.show() D:\pyCharm\PyCharm 2020.2\plugins\python\helpers\pycharm_matplotlib_backend\backend_interagg.py:68: UserWarning: Glyph 36724 (\N{CJK UNIFIED IDEOGRAPH-8F74}) missing from current font. self.figure.tight_layout() D:\pyCharm\PyCharm 2020.2\plugins\python\helpers\pycharm_matplotlib_backend\backend_interagg.py:68: UserWarning: Glyph 25968 (\N{CJK UNIFIED IDEOGRAPH-6570}) missing from current font. self.figure.tight_layout() D:\pyCharm\PyCharm 2020.2\plugins\python\helpers\pycharm_matplotlib_backend\backend_interagg.py:68: UserWarning: Glyph 25454 (\N{CJK UNIFIED IDEOGRAPH-636E}) missing from current font. self.figure.tight_layout() D:\pyCharm\PyCharm 2020.2\plugins\python\helpers\pycharm_matplotlib_backend\backend_interagg.py:68: UserWarning: Glyph 20998 (\N{CJK UNIFIED IDEOGRAPH-5206}) missing from current font. self.figure.tight_layout() D:\pyCharm\PyCharm 2020.2\plugins\python\helpers\pycharm_matplotlib_backend\backend_interagg.py:68: UserWarning: Glyph 26512 (\N{CJK UNIFIED IDEOGRAPH-6790}) missing from current font. self.figure.tight_layout() D:\pyCharm\PyCharm 2020.2\plugins\python\helpers\pycharm_matplotlib_backend\backend_interagg.py:69: UserWarning: Glyph 36724 (\N{CJK UNIFIED IDEOGRAPH-8F74}) missing from current font. FigureCanvasAgg.draw(self) D:\pyCharm\PyCharm 2020.2\plugins\python\helpers\pycharm_matplotlib_backend\backend_interagg.py:69: UserWarning: Glyph 25968 (\N{CJK UNIFIED IDEOGRAPH-6570}) missing from current font. FigureCanvasAgg.draw(self) D:\pyCharm\PyCharm 2020.2\plugins\python\helpers\pycharm_matplotlib_backend\backend_interagg.py:69: UserWarning: Glyph 25454 (\N{CJK UNIFIED IDEOGRAPH-636E}) missing from current font. FigureCanvasAgg.draw(self) D:\pyCharm\PyCharm 2020.2\plugins\python\helpers\pycharm_matplotlib_backend\backend_interagg.py:69: UserWarning: Glyph 20998 (\N{CJK UNIFIED IDEOGRAPH-5206}) missing from current font. FigureCanvasAgg.draw(self) D:\pyCharm\PyCharm 2020.2\plugins\python\helpers\pycharm_matplotlib_backend\backend_interagg.py:69: UserWarning: Glyph 26512 (\N{CJK UNIFIED IDEOGRAPH-6790}) missing from current font. FigureCanvasAgg.draw(self)

D:\python\python3.9.5\python.exe C:/Users/马斌/Desktop/NGSIM_data_processing/80s/x-y.py Traceback (most recent call last): File "C:\Users\马斌\Desktop\NGSIM_data_processing\80s\x-y.py", line 6, in <module> data = pd.read_csv('车辆:1499序:2结果数据换算单位.csv') File "D:\python\python3.9.5\lib\site-packages\pandas\io\parsers\readers.py", line 912, in read_csv return _read(filepath_or_buffer, kwds) File "D:\python\python3.9.5\lib\site-packages\pandas\io\parsers\readers.py", line 577, in _read parser = TextFileReader(filepath_or_buffer, **kwds) File "D:\python\python3.9.5\lib\site-packages\pandas\io\parsers\readers.py", line 1407, in __init__ self._engine = self._make_engine(f, self.engine) File "D:\python\python3.9.5\lib\site-packages\pandas\io\parsers\readers.py", line 1679, in _make_engine return mapping[engine](f, **self.options) File "D:\python\python3.9.5\lib\site-packages\pandas\io\parsers\c_parser_wrapper.py", line 93, in __init__ self._reader = parsers.TextReader(src, **kwds) File "pandas\_libs\parsers.pyx", line 548, in pandas._libs.parsers.TextReader.__cinit__ File "pandas\_libs\parsers.pyx", line 637, in pandas._libs.parsers.TextReader._get_header File "pandas\_libs\parsers.pyx", line 848, in pandas._libs.parsers.TextReader._tokenize_rows File "pandas\_libs\parsers.pyx", line 859, in pandas._libs.parsers.TextReader._check_tokenize_status File "pandas\_libs\parsers.pyx", line 2017, in pandas._libs.parsers.raise_parser_error UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb1 in position 0: invalid start byte Process finished with exit code 1

import pandas as pd import numpy as np import matplotlib.pyplot as plt import tensorflow as tf from tensorflow.keras.models import Sequential from tensorflow.keras.layers import LSTM, Dense data = pd.read_csv('车辆:274序:4结果数据.csv') x = data[['车头间距', '原车道前车速度']].values y = data['本车速度'].values train_size = int(len(x) * 0.7) test_size = len(x) - train_size x_train, x_test = x[0:train_size,:], x[train_size:len(x),:] y_train, y_test = y[0:train_size], y[train_size:len(y)] from sklearn.preprocessing import MinMaxScaler scaler = MinMaxScaler(feature_range=(0, 1)) x_train = scaler.fit_transform(x_train) x_test = scaler.transform(x_test) model = Sequential() model.add(LSTM(50, input_shape=(2, 1))) model.add(Dense(1)) model.compile(loss='mean_squared_error', optimizer='adam') history = model.fit(x_train.reshape(-1, 2, 1), y_train, epochs=100, batch_size=32, validation_data=(x_test.reshape(-1, 2, 1), y_test)) plt.plot(history.history['loss']) plt.plot(history.history['val_loss']) plt.title('Model loss') plt.ylabel('Loss') plt.xlabel('Epoch') plt.legend(['Train', 'Test'], loc='upper right') plt.show() train_predict = model.predict(x_train.reshape(-1, 2, 1)) test_predict = model.predict(x_test.reshape(-1, 2, 1)) train_predict = scaler.inverse_transform(train_predict) train_predict = train_predict.reshape(-1) # 将结果变为一维数组 y_train = scaler.inverse_transform(y_train.reshape(-1, 1)).reshape(-1) # 将结果变为一维数组 test_predict = scaler.inverse_transform(test_predict) y_test = scaler.inverse_transform([y_test]) plt.plot(y_train[0], label='train') plt.plot(train_predict[:,0], label='train predict') plt.plot(y_test[0], label='test') plt.plot(test_predict[:,0], label='test predict') plt.legend() plt.show()报错Traceback (most recent call last): File "C:\Users\马斌\Desktop\NGSIM_data_processing\80s\lstmtest.py", line 42, in <module> train_predict = scaler.inverse_transform(train_predict) File "D:\python\python3.9.5\pythonProject\venv\lib\site-packages\sklearn\preprocessing\_data.py", line 541, in inverse_transform X -= self.min_ ValueError: non-broadcastable output operand with shape (611,1) doesn't match the broadcast shape (611,2)

最新推荐

recommend-type

resnet模型-基于图像分类算法对汉字写的是否工整识别-不含数据集图片-含逐行注释和说明文档.zip

resnet模型_基于图像分类算法对汉字写的是否工整识别-不含数据集图片-含逐行注释和说明文档 本代码是基于python pytorch环境安装的。 下载本代码后,有个环境安装的requirement.txt文本 如果有环境安装不会的,可自行网上搜索如何安装python和pytorch,这些环境安装都是有很多教程的,简单的 环境需要自行安装,推荐安装anaconda然后再里面推荐安装python3.7或3.8的版本,pytorch推荐安装1.7.1或1.8.1版本 首先是代码的整体介绍 总共是3个py文件,十分的简便 且代码里面的每一行都是含有中文注释的,小白也能看懂代码 然后是关于数据集的介绍。 本代码是不含数据集图片的,下载本代码后需要自行搜集图片放到对应的文件夹下即可 在数据集文件夹下是我们的各个类别,这个类别不是固定的,可自行创建文件夹增加分类数据集 需要我们往每个文件夹下搜集来图片放到对应文件夹下,每个对应的文件夹里面也有一张提示图,提示图片放的位置 然后我们需要将搜集来的图片,直接放到对应的文件夹下,就可以对代码进行训练了。 运行01生成txt.py,
recommend-type

计算机毕业设计选题精品毕设分享+源码+论文+PPT+asp.net0班级网站的设计与实现演示录像.rar

博主给大家详细整理了计算机毕业设计最新项目,对项目有任何疑问(部署跟文档),都可以问博主哦~ 一、JavaWeb管理系统毕设项目【计算机毕设选题】计算机毕业设计选题,500个热门选题推荐,更多作品展示 计算机毕业设计|PHP毕业设计|JSP毕业程序设计|Android毕业设计|Python设计论文|微信小程序设计 更多作品展示 +微亻言 biyesheji02
recommend-type

Reborn 是使用 Go 开发的,基于 Redis 存储的配置库,简单配置,易于使用

Go语言(也称为Golang)是由Google开发的一种静态强类型、编译型的编程语言。它旨在成为一门简单、高效、安全和并发的编程语言,特别适用于构建高性能的服务器和分布式系统。以下是Go语言的一些主要特点和优势: 简洁性:Go语言的语法简单直观,易于学习和使用。它避免了复杂的语法特性,如继承、重载等,转而采用组合和接口来实现代码的复用和扩展。 高性能:Go语言具有出色的性能,可以媲美C和C++。它使用静态类型系统和编译型语言的优势,能够生成高效的机器码。 并发性:Go语言内置了对并发的支持,通过轻量级的goroutine和channel机制,可以轻松实现并发编程。这使得Go语言在构建高性能的服务器和分布式系统时具有天然的优势。 安全性:Go语言具有强大的类型系统和内存管理机制,能够减少运行时错误和内存泄漏等问题。它还支持编译时检查,可以在编译阶段就发现潜在的问题。 标准库:Go语言的标准库非常丰富,包含了大量的实用功能和工具,如网络编程、文件操作、加密解密等。这使得开发者可以更加专注于业务逻辑的实现,而无需花费太多时间在底层功能的实现上。 跨平台:Go语言支持多种操作系统和平台,包括Windows、Linux、macOS等。它使用统一的构建系统(如Go Modules),可以轻松地跨平台编译和运行代码。 开源和社区支持:Go语言是开源的,具有庞大的社区支持和丰富的资源。开发者可以通过社区获取帮助、分享经验和学习资料。 总之,Go语言是一种简单、高效、安全、并发的编程语言,特别适用于构建高性能的服务器和分布式系统。如果你正在寻找一种易于学习和使用的编程语言,并且需要处理大量的并发请求和数据,那么Go语言可能是一个不错的选择。
recommend-type

其他类别Jsp考试系统-jspks.7z

[其他类别]Jsp考试系统_jspks.7z
recommend-type

计算机毕业设计选题精品毕设分享+源码+论文+PPT+asp.net15图书馆借阅管理系统多用户(无论文)录像.rar

博主给大家详细整理了计算机毕业设计最新项目,对项目有任何疑问(部署跟文档),都可以问博主哦~ 一、JavaWeb管理系统毕设项目【计算机毕设选题】计算机毕业设计选题,500个热门选题推荐,更多作品展示 计算机毕业设计|PHP毕业设计|JSP毕业程序设计|Android毕业设计|Python设计论文|微信小程序设计 更多作品展示 +微亻言 biyesheji02
recommend-type

zigbee-cluster-library-specification

最新的zigbee-cluster-library-specification说明文档。
recommend-type

管理建模和仿真的文件

管理Boualem Benatallah引用此版本:布阿利姆·贝纳塔拉。管理建模和仿真。约瑟夫-傅立叶大学-格勒诺布尔第一大学,1996年。法语。NNT:电话:00345357HAL ID:电话:00345357https://theses.hal.science/tel-003453572008年12月9日提交HAL是一个多学科的开放存取档案馆,用于存放和传播科学研究论文,无论它们是否被公开。论文可以来自法国或国外的教学和研究机构,也可以来自公共或私人研究中心。L’archive ouverte pluridisciplinaire
recommend-type

MATLAB取整函数与Web开发的作用:round、fix、floor、ceil在Web开发中的应用

![MATLAB取整函数与Web开发的作用:round、fix、floor、ceil在Web开发中的应用](https://img-blog.csdnimg.cn/2020050917173284.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2thbmdqaWVsZWFybmluZw==,size_16,color_FFFFFF,t_70) # 1. MATLAB取整函数概述** MATLAB取整函数是一组强大的工具,用于对数值进行
recommend-type

我想做python的算法工程师,我应该学什么?学习的顺序是什么?网上有什么推荐的免费课程吗?回答具体精确一点不要太笼统

对于想要成为 Python 算法工程师的人来说,他们应该先从掌握 Python 的基础语法开始,然后学习数据结构和算法,并且要深入了解 Python 中的一些科学计算和数据处理库,比如 NumPy、Pandas 等。 学习的顺序可以是先学习基础语法和编程技巧,然后再学习数据结构和算法相关的知识,最后深入了解数据处理和科学计算相关的库。 对于免费课程的推荐,我建议你可以先去 Coursera、edX、Udacity 等网站上寻找相关课程,这些网站上有很多优质的 Python 编程和算法课程,你可以根据自己的需求和学习进度进行选择。此外,还可以考虑一些在线编程网站,如 HackerRank、L
recommend-type

JSBSim Reference Manual

JSBSim参考手册,其中包含JSBSim简介,JSBSim配置文件xml的编写语法,编程手册以及一些应用实例等。其中有部分内容还没有写完,估计有生之年很难看到完整版了,但是内容还是很有参考价值的。