会员可以在此提问,百战程序员老师有问必答
对大家有帮助的问答会被标记为“推荐”
看完课程过来浏览一下别人提的问题,会帮你学得更全面
截止目前,同学们一共提了 132463个问题

老师为什么break和continue报错

import java.util.Scanner;
public class Testmyself {
    public static void main(String[] args){
        Scanner s =new Scanner(System.in);
        System.out.println("你的月薪是多少");
        double monthsalary =s.nextInt();
        double J =(monthsalary-5000-50);
        double sui = 0;
        if (J<0){
            System.out.println("不需要纳税");
        }else if (J<3000){
            sui=(J*0.03);
            monthsalary-=sui;
        }else if(J<12000){
            sui=(J*0.1)-210;
            monthsalary-=sui;
        }else if(J<25000){
            sui=(J*0.2)-1410;
        }else if (J<35000){
            sui=(J*0.25)-2660;
            monthsalary-=sui;
        }else if (J<55000){
            sui=(J*0.3)-4410;
            monthsalary-=sui;
        }else if(J<80000){
            sui=(J*0.35)-7160;
            monthsalary-=sui;
        }else if (J>80000){
            sui=(J*0.45)-15160;
            monthsalary-=sui;
        }
        System.out.println("应纳税所得额"+J+"元\t"+"纳税税额"+sui+"元\t"+"实际工资"+monthsalary+"元");
        System.out.println("输入88退出,输入66,继续") ;
            int k = s.nextInt();
            if (k == 88) {
                System.out.println("退出");
                break;
            } else if (k == 66) {
                continue;
            }

    }

}


JAVA 全系列/第一阶段:JAVA 快速入门/控制语句、方法、递归算法 12826楼
JAVA 全系列/第五阶段:JavaWeb开发/Ajax技术详解(旧) 12827楼

import pickle

import numpy as np
from sklearn.linear_model import LogisticRegression
X = []
Y = []
genre_list = ['blues', 'classical', 'country', "disco", 'hiphop', 'jazz', 'metal']
for g in genre_list:
    for n in range(100):
        rad = "d:/BaiduNetdiskDownload/trainset/" +g+'.'+str(n).zfill(5)+'.fft'+'.npy'
        fft_features = np.load(rad)
        X.append(fft_features)
        Y.append(genre_list.index(g))
X = np.array(X)
Y = np.array(Y)
model = LogisticRegression()
model.fit(X,Y)

output = open('model.pkl', 'wb')
pickle.dump(model, output)
output.close()




D:\anaconda\envs\TF2.1\python.exe C:/Users/LENOVO/PycharmProjects/ai_tensorflow2.6/music_classify/music_classifier.py
C:\Users\LENOVO\PycharmProjects\ai_tensorflow2.6\music_classify\music_classifier.py:14: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray
  X = np.array(X)
TypeError: only size-1 arrays can be converted to Python scalars
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "C:\Users\LENOVO\PycharmProjects\ai_tensorflow2.6\music_classify\music_classifier.py", line 17, in <module>
    model.fit(X,Y)
  File "D:\anaconda\envs\TF2.1\lib\site-packages\sklearn\linear_model\_logistic.py", line 1508, in fit
    X, y = self._validate_data(
  File "D:\anaconda\envs\TF2.1\lib\site-packages\sklearn\base.py", line 581, in _validate_data
    X, y = check_X_y(X, y, **check_params)
  File "D:\anaconda\envs\TF2.1\lib\site-packages\sklearn\utils\validation.py", line 964, in check_X_y
    X = check_array(
  File "D:\anaconda\envs\TF2.1\lib\site-packages\sklearn\utils\validation.py", line 746, in check_array
    array = np.asarray(array, order=order, dtype=dtype)
  File "D:\anaconda\envs\TF2.1\lib\site-packages\numpy\core\_asarray.py", line 83, in asarray
    return array(a, dtype, copy=False, order=order)
ValueError: setting an array element with a sequence.

请老师看看为啥创建模型这里报错了

Python 全系列/第二十三阶段:人工智能基础_机器学习理论和实战(旧)/Softmax回归 12829楼

import pickle

import numpy as np
from sklearn.linear_model import LogisticRegression
X = []
Y = []
genre_list = ['blues', 'classical', 'country', "disco", 'hiphop', 'jazz', 'metal']
for g in genre_list:
    for n in range(100):
        rad = "d:/BaiduNetdiskDownload/trainset/" +g+'.'+str(n).zfill(5)+'.fft'+'.npy'
        fft_features = np.load(rad)
        X.append(fft_features)
        Y.append(genre_list.index(g))
X = np.array(X)
Y = np.array(Y)
model = LogisticRegression()
model.fit(X,Y)

output = open('model.pkl', 'wb')
pickle.dump(model, output)
output.close()



D:\anaconda\envs\TF2.1\python.exe C:/Users/LENOVO/PycharmProjects/ai_tensorflow2.6/sigmoid/asdsada.py
C:\Users\LENOVO\PycharmProjects\ai_tensorflow2.6\sigmoid\asdsada.py:20: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray
  X = np.array(X)
TypeError: only size-1 arrays can be converted to Python scalars

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\LENOVO\PycharmProjects\ai_tensorflow2.6\sigmoid\asdsada.py", line 25, in <module>
    model.fit(X, y)
  File "D:\anaconda\envs\TF2.1\lib\site-packages\sklearn\linear_model\_logistic.py", line 1508, in fit
    X, y = self._validate_data(
  File "D:\anaconda\envs\TF2.1\lib\site-packages\sklearn\base.py", line 581, in _validate_data
    X, y = check_X_y(X, y, **check_params)
  File "D:\anaconda\envs\TF2.1\lib\site-packages\sklearn\utils\validation.py", line 964, in check_X_y
    X = check_array(
  File "D:\anaconda\envs\TF2.1\lib\site-packages\sklearn\utils\validation.py", line 746, in check_array
    array = np.asarray(array, order=order, dtype=dtype)
  File "D:\anaconda\envs\TF2.1\lib\site-packages\numpy\core\_asarray.py", line 83, in asarray
    return array(a, dtype, copy=False, order=order)
ValueError: setting an array element with a sequence.

进程已结束,退出代码1

请老师帮我看看为啥报错了

Python 全系列/第二十三阶段:人工智能基础_机器学习理论和实战(旧)/Softmax回归 12830楼
JAVA 全系列/第九阶段:Spring Boot实战/Spring Boot 12831楼
Python 全系列/第八阶段:轻量级Web开发利器-Flask框架/Flask数据库 12832楼
JAVA 全系列/第九阶段:Spring Boot实战/Spring Boot 12833楼
Python 全系列/第二阶段:Python 深入与提高/文件处理 12838楼
Python 全系列/第二阶段:Python 深入与提高/文件处理 12839楼
Python 全系列/第二阶段:Python 深入与提高/文件处理 12840楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园
网站维护:百战汇智(北京)科技有限公司
京公网安备 11011402011233号    京ICP备18060230号-3    营业执照    经营许可证:京B2-20212637