【Python】报错荟萃

1.RuntimeError: Trying to backward through the graph a second time (or directly access saved variables after they have already been freed). Saved intermediate values of the graph are freed when you call .backward() or autograd.grad(). Specify retain_graph=True if you need to backward through the graph a second time or if you need to access saved variables after calling backward.

解决方法:网上较多的是针对一个网络有多个输出分别进行梯度下降的情况,我遇到的则是Softmax和Parameter同时在一条语句中使用时报错,解决方法是去掉Softmax

2.File “D:\Projects\Flow\Flow_Forecast\venv\lib\site-packages\psycopg2_init_.py”, line 122, in connect conn = _connect(dsn, connection_factory=connection_factory, **kwasync) psycopg2.OperationalError

解决方法:这是一个很笼统的报错,以至于我没看出来。后来发现是字母大小写的问题,postgresql使用python新建表单和数据库时大写字母被强制转为小写,但在读取数据库和表的时候却分大小写,所以这边初始化报错了。建议postgresql中的名字都用小写。

3.TypeError: can’t convert np.ndarray of type numpy.object_. The only supported types are: float64……

解决方法:强制类型转换 x.astype(None),变更为普通数组

4.numpy.core._exceptions._ArrayMemoryError: Unable to allocate 3.99 MiB for an array with shape (39, 13410) and data type object

解决方法:这是读取数据内存溢出的问题。重跑模型或者优化内存配置

5.ufunc ‘isnan’ not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ‘‘safe’’

解决方法:np.nan(a)中的a的类型有问题,修改为np.nan(a.astype(None))即可。

猜你喜欢

转载自blog.csdn.net/qq_43166192/article/details/130491524
今日推荐