反归一化时报错ValueError: operands could not be broadcast together with shapes

在使用scaler.inverse_transform(y_test)进行反归一化时,报错ValueError: operands could not be broadcast together with shapes (984,2) (4,)(984,2),我断调试了一下,在这个位置报错:图片说明

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
Python+OpenCV计算机视觉

Python+OpenCV计算机视觉

报错ValueError: None values not supported.如何解决

在跑代码的时候出现了ValueError: None values not supported. 停在了这里,这是我定义的class 应该是调用fit函数时候出现的问题 ``` class NetworkBase(object): def train(self, x_train, y_train, x_test, y_test, epochs, batch_size, log_dir='/tmp/fullyconnected', stop_early=False): callbacks = [] if backend._BACKEND == 'tensorflow': callbacks.append(TensorBoard(log_dir=log_dir)) if stop_early: callbacks.append(EarlyStopping(monitor='val_loss', patience=2, verbose=1, mode='auto')) self.fcnet.fit(x_train, y_train, epochs=epochs, batch_size=batch_size, shuffle=True, validation_data=(x_test, y_test), callbacks=callbacks) ``` 报错信息如下 ``` File "D:\R\实验室\代码\DL-hybrid-precoder-master\main_train\Model\network_base.py", line 20, in train callbacks=callbacks) File "C:\Users\admin\Anaconda3\lib\site-packages\keras\engine\training.py", line 1213, in fit self._make_train_function() File "C:\Users\admin\Anaconda3\lib\site-packages\keras\engine\training.py", line 316, in _make_train_function loss=self.total_loss) File "C:\Users\admin\Anaconda3\lib\site-packages\keras\legacy\interfaces.py", line 91, in wrapper return func(*args, **kwargs) File "C:\Users\admin\Anaconda3\lib\site-packages\keras\optimizers.py", line 543, in get_updates p_t = p - lr_t * m_t / (K.sqrt(v_t) + self.epsilon) File "C:\Users\admin\Anaconda3\lib\site-packages\tensorflow\python\ops\math_ops.py", line 815, in binary_op_wrapper y = ops.convert_to_tensor(y, dtype=x.dtype.base_dtype, name="y") File "C:\Users\admin\Anaconda3\lib\site-packages\tensorflow\python\framework\ops.py", line 1039, in convert_to_tensor return convert_to_tensor_v2(value, dtype, preferred_dtype, name) File "C:\Users\admin\Anaconda3\lib\site-packages\tensorflow\python\framework\ops.py", line 1097, in convert_to_tensor_v2 as_ref=False) File "C:\Users\admin\Anaconda3\lib\site-packages\tensorflow\python\framework\ops.py", line 1175, in internal_convert_to_tensor ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref) File "C:\Users\admin\Anaconda3\lib\site-packages\tensorflow\python\framework\constant_op.py", line 304, in _constant_tensor_conversion_function return constant(v, dtype=dtype, name=name) File "C:\Users\admin\Anaconda3\lib\site-packages\tensorflow\python\framework\constant_op.py", line 245, in constant allow_broadcast=True) File "C:\Users\admin\Anaconda3\lib\site-packages\tensorflow\python\framework\constant_op.py", line 283, in _constant_impl allow_broadcast=allow_broadcast)) File "C:\Users\admin\Anaconda3\lib\site-packages\tensorflow\python\framework\tensor_util.py", line 454, in make_tensor_proto raise ValueError("None values not supported.") ValueError: None values not supported. ``` 希望有大神可以帮我解答问题出在哪里

RK3288 make otapackage 报错ValueError: need more than 1 value to unpack

mkbootimg_args = (str) multistage_support = (str) 1 recovery_api_version = (int) 2 selinux_fc = (str) /tmp/targetfiles-WQjmn2/BOOT/RAMDISK/file_contexts system_size = (int) 1610612736 tool_extensions = (str) device/rockchip/rksdk update_rename_support = (str) 1 use_set_metadata = (str) 1 using device-specific extensions in device/rockchip/rksdk building image from target_files RECOVERY... running: mkbootfs -f /tmp/targetfiles-WQjmn2/META/recovery_filesystem_config.txt /tmp/targetfiles-WQjmn2/RECOVERY/RAMDISK running: minigzip running: mkbootimg --kernel /tmp/targetfiles-WQjmn2/RECOVERY/kernel --second /tmp/targetfiles-WQjmn2/RECOVERY/resource.img --ramdisk /tmp/tmpBdTCrB --output /tmp/tmpNnUZoC running: drmsigntool /tmp/tmpNnUZoC build/target/product/security/privateKey.bin src_path: /tmp/tmpNnUZoC, private_key_path: build/target/product/security/privateKey.bin can't open file build/target/product/security/privateKey.bin! no find private key, so not sign boot.img! building image from target_files BOOT... running: mkbootfs -f /tmp/targetfiles-WQjmn2/META/boot_filesystem_config.txt /tmp/targetfiles-WQjmn2/BOOT/RAMDISK running: minigzip running: mkbootimg --kernel /tmp/targetfiles-WQjmn2/BOOT/kernel --second /tmp/targetfiles-WQjmn2/BOOT/resource.img --ramdisk /tmp/tmp6LpDeb --output /tmp/tmppqQcvT running: drmsigntool /tmp/tmppqQcvT build/target/product/security/privateKey.bin src_path: /tmp/tmppqQcvT, private_key_path: build/target/product/security/privateKey.bin can't open file build/target/product/security/privateKey.bin! no find private key, so not sign boot.img! running: imgdiff -b /tmp/targetfiles-WQjmn2/SYSTEM/etc/recovery-resource.dat /tmp/tmpD07dY4 /tmp/tmpXulEpX /tmp/tmp1qudyL Traceback (most recent call last): File "./build/tools/releasetools/ota_from_target_files", line 1059, in <module> main(sys.argv[1:]) File "./build/tools/releasetools/ota_from_target_files", line 1027, in main WriteFullOTAPackage(input_zip, output_zip) File "./build/tools/releasetools/ota_from_target_files", line 502, in WriteFullOTAPackage Item.GetMetadata(input_zip) File "./build/tools/releasetools/ota_from_target_files", line 197, in GetMetadata key, value = element.split("=") ValueError: need more than 1 value to unpack make: *** [out/target/product/rk3288/rk3288-ota-eng.wake.zip] 错误 1

Keras报错 ‘ValueError: 'pool5' is not in list’

很长的一个project,在keras下实现VGG16。 这是报错的整个代码段: ``` for roi, roi_context in zip(rois, rois_context): ins = [im_in, dmap_in, np.array([roi]), np.array([roi_context])] print("Testing ROI {c}") subtimer.tic() blobs_out = model.predict(ins) subtimer.toc() print("Storing Results") print(layer_names) post_roi_layers = set(layer_names[layer_names.index("pool5"):]) for name, val in zip(layer_names, blobs_out): if name not in outs: outs[name] = val else: if name in post_roi_layers: outs[name] = np.concatenate([outs[name], val]) c += 1 ``` 报错信息: ``` Loading Test Data data is loaded from roidb_test_19_smol.pkl Number of Images to test: 10 Testing ROI {c} Storing Results ['cls_score', 'bbox_pred_3d'] Traceback (most recent call last): File "/Users/xijiejiao/Amodal3Det_TF/tfmodel/main.py", line 6, in <module> results = test_main.test_tf_implementation(cache_file="roidb_test_19_smol.pkl", weights_path="rgbd_det_iter_40000.h5") File "/Users/xijiejiao/Amodal3Det_TF/tfmodel/test_main.py", line 36, in test_tf_implementation results = test.test_net(tf_model, roidb) File "/Users/xijiejiao/Amodal3Det_TF/tfmodel/test.py", line 324, in test_net im_detect_3d(net, im, dmap, test['boxes'], test['boxes_3d'], test['rois_context']) File "/Users/xijiejiao/Amodal3Det_TF/tfmodel/test.py", line 200, in im_detect_3d post_roi_layers = set(layer_names[layer_names.index("pool5"):]) ValueError: 'pool5' is not in list ```

python 报错ValueError: cannot reindex from a duplicate axis ,但是我查看que'mei'you没有重复索引。

问题是这样的: 并没有出现重复的索引,但是任然报错! 我试了几下,如果去掉#first way中的代码,代码就可以正常运行。 ![图片说明](https://img-ask.csdn.net/upload/202006/13/1592044312_286779.png) 不去#first way代码的运行结果为: ![图片说明](https://img-ask.csdn.net/upload/202006/13/1592044572_439753.png) 求大神解答!!

python操作word报错ValueError: can only parse strings。

1、问题描述: 学习Python操作word文件,使用render()方法时报错ValueError: can only parse strings。 2、相关代码 ``` # _*_ encoding:utf-8 _*_ from docxtpl import DocxTemplate data_dic = { 't1':'燕子', 't2':'杨柳', 't3':'桃花', 't4':'针尖', 't5':'头涔涔', 't6':'泪潸潸', 't7':'茫茫然', 't8':'伶伶俐俐', } doc = DocxTemplate("/test/test.doc") #加载模板文件 doc.render(data_dic) #填充数据 doc.save("/test/target.doc") ``` 3、模板信息: ``` {{r t1}}去了,有再来的时候;{{r t2}}枯了,有再青的时候;{{r t3}}谢了,有再开的时候。但是,聪明的,你告诉我,我们的日子为什么一去不复返呢?——是有人偷了他们罢:那是谁?又藏在何处呢?是他们自己逃走了罢:现在又到了哪里呢? 我不知道他们给了我多少日子;但我的手确乎是渐渐空虚了。在默默里算着,八千多日子已经从我手中溜去;像{{r t4}}上一滴水滴在大海里,我的日子滴在时间的流里,没有声音,也没有影子。我不禁{{r t5}}而{{r t6}}了。 去的尽管去了,来的尽管来着;去来的中间,又怎样地匆匆呢?早上我起来的时候,小屋里射进两三方斜斜的太阳。太阳他有脚啊,轻轻悄悄地挪移了;我也{{r t7}}跟着旋转。于是——洗手的时候,日子从水盆里过去;吃饭的时候,日子从饭碗里过去;默默时,便从凝然的双眼前过去。我觉察他去的匆匆了,伸出手遮挽时,他又从遮挽着的手边过去,天黑时,我躺在床上,他便{{r t8}}地从我身上跨过,从我脚边飞去了。等我睁开眼和太阳再见,这算又溜走了一日。我掩着面叹息。但是新来的日子的影儿又开始在叹息里闪过了。 ``` 4、报错信息: ![图片说明](https://img-ask.csdn.net/upload/202001/15/1579068250_471502.png) 5、相关依赖包版本 ``` doc 0.1.0 docx 0.2.4 docxtpl 0.6.3 lxml 3.2.1 Jinja2 2.10.3 ``` 6、我尝试更换了lxml的版本发现报错信息一样。我又尝试跟踪错误,在这个文件里: ![图片说明](https://img-ask.csdn.net/upload/202001/15/1579068951_317573.png) 打印了一下text: ![图片说明](https://img-ask.csdn.net/upload/202001/15/1579068974_898727.png) 发现有一步text为None: ![图片说明](https://img-ask.csdn.net/upload/202001/15/1579069045_944104.png) 7、所以想问一下有没有大佬遇到并解决过这个问题,怎么解决这个问题。救救一下小萌新吧,还有就是val._target._blob这个变量里存的是什么数据,为什么会出现None的情况?谢谢大佬的指点! 8、追加: 问题暂时得到了解决,我在get_headers_footers_xml这个函数里添加了不为空的判断if val._target._blob != None:yield relKey, self.xml_to_string(parse_xml(val._target._blob)) 就不再报错并且成功写入到目标文件里,但是我仍然不清楚这是不是依赖包本身的BUG。如果有大佬知道的话请指点我一下。如果也有遇到这个问题的朋友,可以试一试我这个方法暂时解决一下。下面是我修改的图片: ![图片说明](https://img-ask.csdn.net/upload/202001/15/1579074850_454765.png)

openpyxl.load__workbook(filename)报错ValueError: Max value is 52

openpyxl.load__workbook(filename)报错ValueError: Max value is 52,但是只有个别表格会出现报错,什么原因? ``` import openpyxl filename="测试2.xlsx"#读取excel workbook=openpyxl.load_workbook(filename,data_only=True) worksheet=workbook.get_sheet_by_name("Sheet1") ``` 报错信息如下: ``` File "C:\Users\mayn\AppData\Local\Programs\Python\Python36\lib\site-packages\openpyxl\reader\excel.py", line 314, in load_workbook reader.read() File "C:\Users\mayn\AppData\Local\Programs\Python\Python36\lib\site-packages\openpyxl\reader\excel.py", line 279, in read self.read_worksheets() File "C:\Users\mayn\AppData\Local\Programs\Python\Python36\lib\site-packages\openpyxl\reader\excel.py", line 254, in read_worksheets charts, images = find_images(self.archive, rel.target) File "C:\Users\mayn\AppData\Local\Programs\Python\Python36\lib\site-packages\openpyxl\reader\drawings.py", line 27, in find_images drawing = SpreadsheetDrawing.from_tree(tree) File "C:\Users\mayn\AppData\Local\Programs\Python\Python36\lib\site-packages\openpyxl\descriptors\serialisable.py", line 87, in from_tree obj = desc.expected_type.from_tree(el) File "C:\Users\mayn\AppData\Local\Programs\Python\Python36\lib\site-packages\openpyxl\descriptors\serialisable.py", line 87, in from_tree obj = desc.expected_type.from_tree(el) File "C:\Users\mayn\AppData\Local\Programs\Python\Python36\lib\site-packages\openpyxl\descriptors\serialisable.py", line 87, in from_tree obj = desc.expected_type.from_tree(el) [Previous line repeated 3 more times] File "C:\Users\mayn\AppData\Local\Programs\Python\Python36\lib\site-packages\openpyxl\descriptors\serialisable.py", line 103, in from_tree return cls(**attrib) File "C:\Users\mayn\AppData\Local\Programs\Python\Python36\lib\site-packages\openpyxl\drawing\text.py", line 115, in __init__ self.pitchFamily = pitchFamily File "C:\Users\mayn\AppData\Local\Programs\Python\Python36\lib\site-packages\openpyxl\descriptors\base.py", line 108, in __set__ super(Min, self).__set__(instance, value) File "C:\Users\mayn\AppData\Local\Programs\Python\Python36\lib\site-packages\openpyxl\descriptors\base.py", line 87, in __set__ raise ValueError('Max value is {0}'.format(self.max)) ValueError: Max value is 52 ```

ValueError: could not broadcast input array from shape (100,100,3) into shape (100,100)

path是图片的路径 w,h是图片的设定长宽 ```def read_img(path): cate=[path+x for x in os.listdir(path) if os.path.isdir(path+x)] imgs=[] labels=[] for idx,folder in enumerate(cate): for im in glob.glob(folder+'/*.jpg'): print('reading the images:%s'%(im)) img=io.imread(im) img=transform.resize(img,(w,h)) imgs.append(img) labels.append(idx) return np.asarray(imgs,np.float32),np.asarray(labels,np.int32) data,label=read_img(path) ``` 我运行花卉图片加载的时候无错误,但换个路径运行猫狗识别的时候就报错 File "C:/Users/spirit/Desktop/实验练习/tensorflow/猫狗识别/训练模型/猫狗识别.py", line 34, in <module>data,label=read_img(path) File "C:/Users/spirit/Desktop/实验练习/tensorflow/猫狗识别/训练模型/猫狗识别.py", line 31, in read_img return np.asarray(imgs,np.float32),np.asarray(labels,np.int32) File "D:\Anaconda\envs\tensorflow\lib\site-packages\numpy\core\numeric.py", line 501, in asarray return array(a, dtype, copy=False, order=order) ValueError: could not broadcast input array from shape (100,100,3) into shape (100,100) 我真心不懂,只是换了其他图片加载,为什么就报错,真心求教! 我在想是不是我的猫狗图片出了问题,但看了也感觉没什么问题啊,头痛

python错误:ValueError: No JSON object could be decoded

#-*- coding:utf-8 -*- import requests from operator import itemgetter # 执行API调用并存储响应 url = 'http://hacker-news.firebaseio.com/v0/topstories.json' r = requests.get(url) print("Status code:", r.status_code) # 处理有关每篇文章的信息 submission_ids = r.json() submission_dicts = [] for submission_id in submission_ids[:30]: # 对于每篇文章,都执行一个API调用 url = ('http://hacker-news.firebaseio.com/v0/item/' + str(submission_id) + '.json') submission_r = requesets.get(url) print(submisssion_r.status_code) reponse_dict = submission_r.json() submission_dict = { 'title': resopnse_dict['title'], 'link': 'http://news.ycombinator.com/item?id=' + str(submission_id), 'comments': response_dict.get('descendants', 0) } submission_dicts.append(submission_dict) submission_dicts = sorted(submission_dicts, key=itemgetter('comments'), recerse=Ture) for submission_dict in submission_dicts: print("/nTitle:", submission_dict['title']) print("Discussion link:", submission_dict['link']) print("Comeents", submission_dict['comments'])

在Cent OS中复现已发表文章的 神经网络训练过程,报错ValueError: low >= high

``` Traceback (most recent call last): File "trainIEEE39LoadSheddingAgent.py", line 139, in <module> env.reset() File "/root/RLGC/src/py/PowerDynSimEnvDef_v3.py", line 251, in reset fault_bus_idx = np.random.randint(0, total_fault_buses)# an integer, in the range of [0, total_bus_num-1] File "mtrand.pyx", line 630, in numpy.random.mtrand.RandomState.randint File "bounded_integers.pyx", line 1228, in numpy.random.bounded_integers._rand_int64 ValueError: low >= high ``` 报错如上,为什么会这样报错?如何解决?谢谢!

爬虫过程中遇到报错:ValueError: can only parse strings

源代码如下: import requests import json from requests.exceptions import RequestException import time from lxml import etree def get_one_page(url): try: headers = { 'User-Agent': 'Mozilla/5.0(Macintosh;Intel Mac OS X 10_13_3) AppleWebKit/537.36(KHTML,like Gecko) Chorme/65.0.3325.162 Safari/537.36' } response = requests.get(url,headers = headers) if response.status_code == 200: return response.text return None except RequestException: return None def parse_one_page(html): html_coner = etree.HTML(html) pattern = html_coner.xpath('//div[@id="container"]/div[@id="main"/div[@class = "ywnr_box"]//a/text()') return pattern def write_to_file(content): with open('results.txt','a',encoding='utf-8') as f: f.write(json.dumps(content,ensure_ascii=False)+'\n') def main(offset): url = 'http://www.cdpf.org.cn/yw/index_'+str(offset)+'.shtml' html = get_one_page(url) for item in parse_one_page(html): print(item) write_to_file(item) if __name__ == '__main__': for i in range(6): main(offset=i*10) time.sleep(1) 请问各位大佬到底是哪里出了错??

在使用机器学习算法过程中报错:ValueError: Incompatible dimension for X and Y matrices: X.shape[1] == 224 while Y.shape[1] == 334

使用KNN算法过程中遇到了ValueError: Incompatible dimension for X and Y matrices: X.shape[1] == 224 while Y.shape[1] == 334 的问题 代码截图:![图片说明](https://img-ask.csdn.net/upload/202005/26/1590474323_300759.png) 报错截图:![图片说明](https://img-ask.csdn.net/upload/202005/26/1590474354_165863.png) 求大佬救救孩子吧

ValueError: multilabel-indicator format is not supported的报错原因?

报错ValueError: multilabel-indicator format is not supported? 这个报错意思比较明确,不支持多分类,但我模型里y的label定义就是0和1,binary,为啥会有这个报错? 一个图像2分类的keras模型,总样本量=120,其中label"0"=110,label"1"=10,非平衡, 代码如下: data = np.load('D:/a.npz') image_data, label_data= data['image'], data['label'] skf = StratifiedKFold(n_splits=3, shuffle=True) for train, test in skf.split(image_data, label_data): train_x=image_data[train] test_x=image_data[test] train_y=label_data[train] test_y=label_data[test] train_x = train_x.reshape(81,50176) test_x = test_x.reshape(39,50176) train_y = keras.utils.to_categorical(train_y,2) test_y = keras.utils.to_categorical(test_y,2) model = Sequential() model.add(Dense(units=128,activation="relu",input_shape=(50176,))) model.add(Dense(units=128,activation="relu")) model.add(Dense(units=128,activation="relu")) model.add(Dense(units=2,activation="sigmoid")) model.compile(optimizer=SGD(0.001),loss="binary_crossentropy",metrics=["accuracy"]) model.fit(train_x, train_y,batch_size=32,epochs=5,verbose=1) y_pred_model = model.predict_proba(test_x)[:,1] fpr_model, tpr_model, _ = roc_curve(test_y, y_pred_model) 报错提示如下: ---> 63 fpr_model, tpr_model, _ = roc_curve(test_y, y_pred_model) ValueError: multilabel-indicator format is not supported

ValueError: None values not supported.

Traceback (most recent call last): File "document_summarizer_training_testing.py", line 296, in <module> tf.app.run() File "/home/lyliu/anaconda3/envs/tensorflowgpu/lib/python3.5/site-packages/tensorflow/python/platform/app.py", line 48, _sys.exit(main(_sys.argv[:1] + flags_passthrough)) File "document_summarizer_training_testing.py", line 291, in main train() File "document_summarizer_training_testing.py", line 102, in train model = MY_Model(sess, len(vocab_dict)-2) File "/home/lyliu/Refresh-master-self-attention/my_model.py", line 70, in __init__ self.train_op_policynet_expreward = model_docsum.train_neg_expectedreward(self.rewardweighted_cross_entropy_loss_multi File "/home/lyliu/Refresh-master-self-attention/model_docsum.py", line 835, in train_neg_expectedreward grads_and_vars_capped_norm = [(tf.clip_by_norm(grad, 5.0), var) for grad, var in grads_and_vars] File "/home/lyliu/Refresh-master-self-attention/model_docsum.py", line 835, in <listcomp> grads_and_vars_capped_norm = [(tf.clip_by_norm(grad, 5.0), var) for grad, var in grads_and_vars] File "/home/lyliu/anaconda3/envs/tensorflowgpu/lib/python3.5/site-packages/tensorflow/python/ops/clip_ops.py", line 107,rm t = ops.convert_to_tensor(t, name="t") File "/home/lyliu/anaconda3/envs/tensorflowgpu/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 676o_tensor as_ref=False) File "/home/lyliu/anaconda3/envs/tensorflowgpu/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 741convert_to_tensor ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref) File "/home/lyliu/anaconda3/envs/tensorflowgpu/lib/python3.5/site-packages/tensorflow/python/framework/constant_op.py", constant_tensor_conversion_function return constant(v, dtype=dtype, name=name) File "/home/lyliu/anaconda3/envs/tensorflowgpu/lib/python3.5/site-packages/tensorflow/python/framework/constant_op.py", onstant tensor_util.make_tensor_proto(value, dtype=dtype, shape=shape, verify_shape=verify_shape)) File "/home/lyliu/anaconda3/envs/tensorflowgpu/lib/python3.5/site-packages/tensorflow/python/framework/tensor_util.py", ake_tensor_proto raise ValueError("None values not supported.") ValueError: None values not supported. 使用tensorflow gpu版本 tensorflow 1.2.0。希望找到解决方法或者出现这个错误的原因

独热编码后遇到问题,ValueError: could not convert string to float: 'C'

![图片说明](https://img-ask.csdn.net/upload/202004/12/1586622503_274496.png)![图片说明](https://img-ask.csdn.net/upload/202004/12/1586622514_126977.png)![图片说明](https://img-ask.csdn.net/upload/202004/12/1586622536_284157.png)

关于python的could not convert string to float的问题。

#!/usr/bin/env python3 #-*- coding: utf-8 -*- import time import subprocess import os from subprocess import call import csv #change offset here offset_peak = 45.0 offset_rsm = 40.0 header_csv = ("time", "amplitude", "rms") try: while True: #pkill because sometimes my microphone was busy subprocess.call("pkill -9 sox | pkill -9 arecord",shell= True) time.sleep( 1 ) #time filedate = time.strftime("%Y%m%d-%H%M%S") filename = "/home/pi/noise/mp3/" + time.strftime("%Y%m%d") + "/" + filedate + ".mp3" filename_csv = "/home/pi/noise/csv/" + time.strftime("%Y%m%d") + ".csv" filedate_csv = time.strftime("%Y-%m-%d %H:%M") terminal_time = time.strftime("%H:%M ") #record subprocess.call("arecord -D hw:1,0 -d 10 -v --fatal-errors --buffer-size=192000 -f dat -t raw --quiet | lame -r --quiet --preset standard - " + filename,shell= True) proc = subprocess.getoutput("sox " + filename + " -n stat 2>&1 | grep 'Maximum amplitude' | cut -d ':' -f 2") proc_rms = subprocess.getoutput("sox " + filename + " -n stat 2>&1 | grep 'RMS.*amplitude' | cut -d ':' -f 2") os.system('clear') proc1 = proc.strip() proc1 = float(proc1) proc_rms = proc_rms.strip() proc_rms = float(proc_rms) #test your microphone in 5 dB steps and create the function e.g. with mycurvefit.com #Fkt 3 30-80 dB proc3 = 83.83064 + (28.34183 - 83.83064)/(1 + (proc1/0.04589368)**1.006258) #Fkt RMS 30-80 dB proc3_rms = 87.69054 + (23.81973 - 87.69054)/(1 + (proc_rms/0.01197014)**0.7397556) #add db filextentions: peak - rms ext_peak = int(round(proc3, 0)) ext_rms = int(round(proc3_rms, 0)) print("Measured values: " + str(proc1) + " / " + str(proc_rms) + " / " + str(proc3) + " / " + str(proc3_rms) + " / " + str(ext_peak) + "\n") #csv file_exists = os.path.isfile(filename_csv) daten_csv = (filedate_csv, proc3, proc3_rms) with open(filename_csv, 'a', newline='') as f: writer = csv.writer(f) if not file_exists: writer.writerow(header_csv) writer.writerow(daten_csv) if proc3 >= offset_peak or proc3_rms >= offset_rsm: print(terminal_time + "Sound detected - save: " + filedate + ".mp3 \n") os.rename(filename, "/home/pi/noise/mp3/" + time.strftime("%Y%m%d") + "/" + filedate + "-" + str(ext_peak) + "-" + str(ext_rms) + ".mp3") time.sleep( 3 ) #os.system('clear') else: print(terminal_time + "No sound detected, delete: " + filedate + ".mp3 \n") os.remove(filename) time.sleep( 3 ) #os.system('clear') except KeyboardInterrupt: subprocess.call("pkill -9 sox | pkill -9 arecord",shell= True) print('End') 详细代码如上,当我运行的时候不知为何python shell显示错误,错误信息如下: Trackback (most recent call last): File:"/home/pi/noise_level_protocol-master/detect.py, line 30 in <module> proc1 = float(proc1) ValueError: could not convert string to float: 希望论坛里的各位大神能够指点迷津, 谢谢。

python调用cv2.findContours时报错:ValueError: not enough values to unpack (expected 3, got 2)

完整代码如下: ``` import cv2 import numpy as np img = np.zeros((200, 200), dtype=np.uint8) img[50:150, 50:150] = 255 ret, thresh = cv2.threshold(img, 127, 255, cv2.THRESH_BINARY) image, contours, hierarchy = cv2.findContours(thresh, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE) color = cv2.cvtColor(img, cv2.COLOR_GRAY2BGR) img = cv2.drawContours(color, contours, -1, (0,255,0), 2) cv2.imshow("contours", color) cv2.waitKey() cv2.destroyAllWindows() ``` 但是cv2.findContours报如下错误: ValueError: not enough values to unpack (expected 3, got 2) python版本为3.6,opencv为4.0.0

在使用KNN算法的时候报错:ValueError: query data dimension must match training data dimension

在使用KNN算法的过程中产生了错误 下图为代码: ![图片说明](https://img-ask.csdn.net/upload/202004/15/1586931262_835281.png) 报错: ![图片说明](https://img-ask.csdn.net/upload/202004/15/1586931388_462897.png) ![图片说明](https://img-ask.csdn.net/upload/202004/15/1586931408_33765.png) 描述的错误信息是:值错误:查询数据维度必须与培训数据维度匹配 但我也不知道该怎么把数据维度匹配起来啊 求大佬帮帮忙,我在网上找了好久都没有解决的办法

python json解析出现No JSON object could be decoded的报错

源代码:#coding:utf-8 import requests import re import json url="http://www.newrank.cn/public/info/list.js?t=1461063208.68" user_agent = 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)' headers = { 'User-Agent' : user_agent } jscontent=requests.get("http://www.newrank.cn/public/info/list.js?t=1461063208.68",headers=headers).content jsdict=json.loads(jscontent) 错误信息:Traceback (most recent call last): File "D:/Python/JetBrains PyCharm 5.0.4/PyCharm 5.0.4/Myproject/test1/test2.py", line 10, in <module> jsdict=json.loads(jscontent) File "D:\Python\lib\json\__init__.py", line 339, in loads return _default_decoder.decode(s) File "D:\Python\lib\json\decoder.py", line 364, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "D:\Python\lib\json\decoder.py", line 382, in raw_decode raise ValueError("No JSON object could be decoded") ValueError: No JSON object could be decoded 是因为json的bom头问题吗,我也尝试过一些网上的去除bom头的办法,不过都不管用,还望指点,非常头疼,谢谢!

ValueError: Unknown mat file type, version 0, 0

训练模型导入.mat文件时出现如下错误: ``` ValueError: Unknown mat file type, version 0, 0 ``` 读取文件代码为: ``` np.array(sio.loadmat(image[0][i])['section'], dtype=np.float32) ``` 望大神指教!不胜感激!

2019 Python开发者日-培训

2019 Python开发者日-培训

150讲轻松搞定Python网络爬虫

150讲轻松搞定Python网络爬虫

设计模式(JAVA语言实现)--20种设计模式附带源码

设计模式(JAVA语言实现)--20种设计模式附带源码

YOLOv3目标检测实战:训练自己的数据集

YOLOv3目标检测实战:训练自己的数据集

java后台+微信小程序 实现完整的点餐系统

java后台+微信小程序 实现完整的点餐系统

三个项目玩转深度学习(附1G源码)

三个项目玩转深度学习(附1G源码)

初级玩转Linux+Ubuntu(嵌入式开发基础课程)

初级玩转Linux+Ubuntu(嵌入式开发基础课程)

2019 AI开发者大会

2019 AI开发者大会

玩转Linux:常用命令实例指南

玩转Linux:常用命令实例指南

一学即懂的计算机视觉(第一季)

一学即懂的计算机视觉(第一季)

4小时玩转微信小程序——基础入门与微信支付实战

4小时玩转微信小程序——基础入门与微信支付实战

Git 实用技巧

Git 实用技巧

Python数据清洗实战入门

Python数据清洗实战入门

使用TensorFlow+keras快速构建图像分类模型

使用TensorFlow+keras快速构建图像分类模型

实用主义学Python(小白也容易上手的Python实用案例)

实用主义学Python(小白也容易上手的Python实用案例)

程序员的算法通关课:知己知彼(第一季)

程序员的算法通关课:知己知彼(第一季)

MySQL数据库从入门到实战应用

MySQL数据库从入门到实战应用

机器学习初学者必会的案例精讲

机器学习初学者必会的案例精讲

手把手实现Java图书管理系统(附源码)

手把手实现Java图书管理系统(附源码)

极简JAVA学习营第四期(报名以后加助教微信:eduxy-1)

极简JAVA学习营第四期(报名以后加助教微信:eduxy-1)

.net core快速开发框架

.net core快速开发框架

玩转Python-Python3基础入门

玩转Python-Python3基础入门

Python数据挖掘简易入门

Python数据挖掘简易入门

微信公众平台开发入门

微信公众平台开发入门

程序员的兼职技能课

程序员的兼职技能课

Windows版YOLOv4目标检测实战:训练自己的数据集

Windows版YOLOv4目标检测实战:训练自己的数据集

HoloLens2开发入门教程

HoloLens2开发入门教程

微信小程序开发实战

微信小程序开发实战

Java8零基础入门视频教程

Java8零基础入门视频教程

相关热词 c#树形选择 c#中类图的使用方法 c# 传参 调用exe c# 怎么定义方法 c# 修改本地时间 c#前台怎么读取资源文件 c# xml转list c#实现框选截图 m*m乘法表c# c# 乘法99表
立即提问