ValueError: y_i value out of bounds

本文记录了使用Theano框架实现LeNet进行人脸识别时遇到的错误:ValueError:y_ivalueoutofbounds,并分享了解决过程及原因分析——标签设置不当。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


用python theano的LeNet做人脸识别的时候,本来是按照手写输入的程序,改一下参数准备train,

然后发现出现错误,ValueError: y_i value out of bounds

感觉是cost_ij = train_model(minibatch_index)的问题

train_model = theano.function(

    [index],
    cost,
    updates=updates,
    givens={
        x: train_set_x[index * batch_size: (index + 1) * batch_size],
        y: train_set_y[index * batch_size: (index + 1) * batch_size]
    }
)

百度了半天,源代码看得晕乎乎的,

最后google了一下,

因为y的标签只能设置[0,n),而我标签设为[1,n]了~~改了一下就OK了


转载于:https://www.cnblogs.com/mandalalala/p/6798267.html

ValueError Traceback (most recent call last) Cell In[36], line 70 67 return df 69 # Apply the outlier processing function ---> 70 df_cleaned = process_outliers(df) Cell In[36], line 61, in process_outliers(df) 59 df[col] = cubic_spline_interpolate(df[col]) 60 elif col in speed_torque_columns: ---> 61 df[col] = linear_interpolate(df[col]) 62 elif col in voltage_current_columns: 63 df[col] = cubic_interpolate(df[col]) Cell In[36], line 33, in process_outliers.<locals>.linear_interpolate(series) 31 y_known = series.dropna().values 32 f = interp1d(x_known, y_known, kind='linear') ---> 33 return f(series.index) File D:\anaconda\Lib\site-packages\scipy\interpolate\_polyint.py:81, in _Interpolator1D.__call__(self, x) 60 """ 61 Evaluate the interpolant 62 (...) 78 79 """ 80 x, x_shape = self._prepare_x(x) ---> 81 y = self._evaluate(x) 82 return self._finish_y(y, x_shape) File D:\anaconda\Lib\site-packages\scipy\interpolate\_interpolate.py:766, in interp1d._evaluate(self, x_new) 764 y_new = self._call(self, x_new) 765 if not self._extrapolate: --> 766 below_bounds, above_bounds = self._check_bounds(x_new) 767 if len(y_new) > 0: 768 # Note fill_value must be broadcast up to the proper size 769 # and flattened to work here 770 y_new[below_bounds] = self._fill_value_below File D:\anaconda\Lib\site-packages\scipy\interpolate\_interpolate.py:799, in interp1d._check_bounds(self, x_new) 797 if self.bounds_error and above_bounds.any(): 798 above_bounds_value = x_new[np.argmax(above_bounds)] --> 799 raise ValueError(f"A value ({above_bounds_value}) in x_new is above " 800 f"the interpolation range's maximum value ({self.x[-1]}).") 802 # !! Should we emit a warning if some values are out of bounds? 803 # !! matlab does not. 804 return below_bounds, above_bounds ValueError: A value (1166205.0) in x_new is above the interpolation range's maximum value (1166204).
最新发布
03-15
ValueError Traceback (most recent call last) Cell In[52], line 69 67 f = interp1d(B2[0, :], B2[1, :], kind='quadratic') 68 a8 = f(i2) ---> 69 a9 = f(a20) 70 derivative = (a9 - a8) / a7 71 if derivative - a9 > 10e-6: File ~\AppData\Roaming\Python\Python39\site-packages\scipy\interpolate\_polyint.py:80, in _Interpolator1D.__call__(self, x) 59 """ 60 Evaluate the interpolant 61 (...) 77 78 """ 79 x, x_shape = self._prepare_x(x) ---> 80 y = self._evaluate(x) 81 return self._finish_y(y, x_shape) File ~\AppData\Roaming\Python\Python39\site-packages\scipy\interpolate\_interpolate.py:752, in interp1d._evaluate(self, x_new) 750 y_new = self._call(self, x_new) 751 if not self._extrapolate: --> 752 below_bounds, above_bounds = self._check_bounds(x_new) 753 if len(y_new) > 0: 754 # Note fill_value must be broadcast up to the proper size 755 # and flattened to work here 756 y_new[below_bounds] = self._fill_value_below File ~\AppData\Roaming\Python\Python39\site-packages\scipy\interpolate\_interpolate.py:786, in interp1d._check_bounds(self, x_new) 784 if self.bounds_error and above_bounds.any(): 785 above_bounds_value = x_new[np.argmax(above_bounds)] --> 786 raise ValueError("A value ({}) in x_new is above " 787 "the interpolation range's maximum value ({})." 788 .format(above_bounds_value, self.x[-1])) 790 # !! Should we emit a warning if some values are out of bounds? 791 # !! matlab does not. 792 return below_bounds, above_bounds ValueError: A value (0.21347609900000009) in x_new is above the interpolation range's maximum value (0.213476099).该怎么修改,代码怎么写
05-24
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值