- 博客(45)
- 收藏
- 关注
原创 AttributeError: ‘numpy.ndarray‘ object has no attribute ‘columns‘
原代码:coef = pd.Series(model_lasso.coef_, index = X_train.columns)改为:coef = pd.Series(model_lasso.coef_, index = X_train.tolist())
2023-08-14 10:59:33
892
原创 python三维变2维
一行代码,Y2_train_hat=np.resize(Y2_train_hat,(400,6))#变成2维了。原来的Y2_train_hat维度是400,6,1。
2023-08-11 11:26:10
589
1
原创 TypeError: only integer scalar arrays can be converted to a scalar index
改为: Py = np.array([ len(np.array(y)[y==yval])/float(len(y)) for yval in y_value_list ]) #P(y)原代码: Py = np.array([ len(y[y==yval])/float(len(y)) for yval in y_value_list ]) #P(y)
2023-08-10 11:42:45
206
原创 RuntimeError: Failed to process string with tex because latex could not be found
加这两行代码就可以运行了。
2023-04-18 15:26:01
268
原创 ValueError: Creating variables on a non-first call to a function decorated with tf.function.解决方法
参考。
2023-03-30 11:09:23
466
原创 时序图横坐标只显示年月
plt.xticks(range(df.shape[0])[::6],df['month_year'][::6])#隔6个月刻度。plt.plot(y, color="royalblue",label='实际值' ,linewidth= '2')plt.plot(yp, color="tomato",label='拟合值' , linewidth= '2')plt.rcParams['font.sans-serif']=['SimHei'] #用来正常显示中文标签。plt.title("拟合图")
2023-03-26 17:26:51
958
原创 不降低版本解决ModuleNotFoundError: No module named ‘tensorflow.contrib‘
替换成:LSTMCell=tf.compat.v1.nn.rnn_cell.BasicLSTMCell。原代码:from tensorflow.contrib.rnn import LSTMCell。
2023-03-15 22:39:53
659
原创 ImportError: cannot import name ‘np_utils‘ from ‘tensorflow.keras‘
改为:from tensorflow.python.keras.utils import np_utils。原代码:from tensorflow.keras.utils import np_utils。
2023-03-15 21:22:57
596
原创 ImportError: cannot import name ‘get_config‘ from
改为:from tensorflow.keras.preprocessing import sequence。原代码:from keras.preprocessing import sequence。
2023-03-15 21:16:28
401
原创 python数据框删掉前几行或者后几行
df.drop(df.tail(n).index) #从尾部去掉 n 行。df.dorp(df.head(n).index) #从头去掉 n 行。
2023-03-12 17:25:23
591
原创 用python3读csv文件,出现UnicodeDecodeError: ‘utf-8‘ codec can‘t decode byte 0xd0 in position 0: invalid con
解决:用记事本打开CSV文件,打开后另存为编码改为utf-8,文件名后加上CSV保存后再运行就可以了。
2023-02-27 16:26:39
577
原创 成功解决 ValueError: Input 0 of layer SDropout_0 is incompatible with the layer: expected ndim=3, found
tcn_out = TCN(lstm_units,kernel_size=3,dilations=[1, 2, 4, 8], return_sequences=True)(drop1) 或。tcn_out = TCN(nb_filters=64,kernel_size=1,dilations=[1, 2, 4, 8])(drop1)或。
2022-12-10 23:07:24
833
原创 成功解决DataFrame object has no attribute ‘as_matrix‘
把原代码:data = stock.as_matrix()改成:data = stock.values。
2022-12-10 21:01:54
2004
原创 成功解决TypeError: fit() got an unexpected keyword argument ‘np_epoch‘
把原代码:history=model.fit(X_train, y_train, np_epoch = epoch, batch_size = 256,shuffle=False,validation_data=(X_test, y_test))改为:history=model.fit(X_train, y_train, epochs = epoch, batch_size = 256,shuffle=False,validation_data=(X_test, y_test))
2022-12-10 20:59:26
3564
原创 解决TypeError: (‘Keyword argument not understood:‘, ‘input‘)
改成model = Model(inputs=[inputs], outputs=output)(输入输出加了S)把原代码:model = Model(input=[inputs], output=output)
2022-12-02 10:10:57
1172
原创 解决K is not defined
新的Keras 版本用 from tensorflow.compat.v1.keras import backend as K。
2022-12-01 16:57:10
594
1
原创 解决ModuleNotFoundError: No module named ‘tensorflow.keras.layers.wrappers‘
是版本不匹配问题,把原代码from tensorflow.keras.layers.wrappers import TimeDistributed。改成from tensorflow.keras.layers import TimeDistributed。
2022-11-30 11:15:37
2987
原创 解决ValueError: Unknown projection ‘3d‘
在代码前加入from mpl_toolkits.mplot3d import Axes3D。
2022-11-27 21:17:19
897
原创 Python成功下载安装hyperopt包
尝试了很多办法都没有下载成功,出错raise ReadTimeoutError(self._pool, None, "Read timed out.") pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnec。好像是是因为下载时间太菜。用pip --default-timeout=1000 install -U hyperopt,下载很慢,如果失败了多试两次就好了。
2022-11-27 15:59:16
916
原创 Python成功下载安装dlib包
下载了百度云的包,保存到用命名的英文的文件里,比如我这个包放到C:/APP/dlib-19.17.99-cp37-cp37m-win_amd64.whl里。用pip install C:/APP/dlib-19.17.99-cp37-cp37m-win_amd64.whl。尝试了很多不同的pip install 都没办法下载,最后看到了这个前辈的方法。
2022-11-27 15:05:53
610
原创 module ‘tensorflow‘ has no attribute ‘layers‘
改成:tf.keras.layers.Laye。把原代码:tf.layers.Layer。
2022-11-24 21:22:37
5030
3
原创 from tensorflow.keras.utils import np_utils报错
改为:from tensorflow.python.keras.utils import np_utils。原代码from tensorflow.keras.utils import np_utils。
2022-11-20 22:42:05
1386
原创 No module named ‘tensorflow.keras.engine
改为:from tensorflow.keras.layers import Layer, InputSpec。原代码:from tensorflow.keras.engine import。
2022-11-20 15:24:52
720
原创 RuntimeError: tf.placeholder() is not compatible with eager execution.
如self.X = tf.compat.v1.placeholder(tf.float32,shape[None,self.time_steps,self.input_dim],name='input_X')在原代码前加 tf.compat.v1.disable_eager_execution()
2022-11-18 17:56:55
570
原创 解决方法 AttributeError: module ‘tensorflow‘ has no attribute ‘contrib‘
原代码 xavier_init = tf.contrib.layers.xavier_initializer(seed=2019)
2022-11-18 17:11:01
682
原创 ModuleNotFoundError: No module named ‘tensorflow.keras.utils.vis_utils‘
原代码:from tensorflow.keras.utils.vis_utils import plot_model。改为:from tensorflow.keras.utils import plot_model。
2022-11-16 11:25:45
1063
原创 解决An exception has occurred, use %tb to see the full traceback. SystemExit: 2问题
改为:args = parser.parse_args(args=[])将原代码 args = parser.parse_args()
2022-11-04 20:51:27
1903
原创 ModuleNotFoundError: No module named ‘tensorflow.keras.utils.generic_utils‘
原来代码from tensorflow.keras.utils.generic_utils import get_custom_objects。改为from tensorflow.keras.utils import get_custom_objects。
2022-11-03 21:15:43
1547
原创 ModuleNotFoundError: No module named ‘tensorflow.keras.layers.embeddings‘
把 from tensorflow.keras.layers.embeddings import Embedding。改成from tensorflow.keras.layers import Embedding。
2022-11-03 21:12:01
1105
原创 ImportError: cannot import name ‘_check_y‘ from ‘sklearn.utils.validation‘ (C:\ProgramData\Anaconda3
改成:from sklearn.utils.validation import check_array as check_arrays。原代码:from sklearn.utils.validation import check_array。
2022-11-01 21:50:21
1985
原创 ModuleNotFoundError: No module named ‘numpy.testing.nosetester‘解决方法
pip install --user --upgrade numpy
2022-11-01 21:37:43
469
原创 WARNING: You are using pip version 21.3.1; however, version 22.0.3 is available.
解决WARNING: You are using pip version 21.3.1; however, version 22.0.3 is available.
2022-10-31 15:19:50
589
原创 target = target.cuda(async = True) ^SyntaxError: invalid syntax
wubksjbvdk
2022-10-15 17:45:59
565
原创 NameError: name ‘logging‘ is not defined解决办法
NameError: name 'logging' is not defined解决办法
2022-10-14 22:22:19
4023
原创 TypeError: Input ‘y‘ of ‘AddV2‘ Op has type int32 that does not match type float32 of argument ‘
运行出错出错: TypeError: Input 'y' of 'AddV2' Op has type int32 that does not match type float32 of argument 'x'.检查发现是损失函数的数据 类型不一致解决办法:用loss_pi=tf.cast(loss_pi,tf.float32)转换成统一的float类型
2022-06-07 11:15:45
1191
原创 解决Python运行错误AttributeError: ‘numpy.ndarray‘ object has no attribute ‘columns‘
把x_train = train.values改为x_train = train就不会报错了
2022-03-28 08:37:27
12364
2
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人