关于归一化和numpy.log处理数据的疑问 5C

在数据挖掘中, 有对数据进行归一化处理,比如StandardNormalization, 这种归一化处理的
好处是对异常的离散数值有很好的效果, 而numpy.log 可以对一些离散的异常数值有这种处理,
经过这种log处理后,得到的直方图更接近高斯分布, 我的问题是:
1. 我在网上看到一些大数据挖掘方面的资料,利用LogisticRegressor, 并没有对数据进行
归一化处理, 这种归一化是否不一定必须的 ?
2. 如果采用了 StandardNormalization 这种归一化处理,是否也相当于采用了Log处理的效果,而且数值被限定在更小的范围之内?
3. 数据挖掘中,如果用到 LogisticRegressor这种算法,是否直接对那些离散值直接进行StandardNormalization处理,不用采用Log处理?

1个回答

(1)是不是必须的要看你的算法。比如说你用了sigmoid之类的激活函数来实现非线性,如果你的数据偏离原点很远,那么就学不起来。就需要归一化。总之,和你的机器学习的算法有关,有的的确差异不大。
(2)不是,标准归一化是将数据按照正态分布处理,均值为0,方差为1,不是指数归一化。
(3)逻辑回归用StandardNormalization就可以了,最好使用修正正切(ReLU)之类的非线性函数。

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
Python用tar.gz文件安装时出现错误:No module named 'numpy.distutils._msvccompiler' in numpy.distutils及Unable to find vcvarsall.bat
系统win10 64位,python版本3.7.4。 在网上下载了scikit-learn-0.22.tar,解压后利用python setup.py install进行安装时报错。 代码如下: ``` PS C:\Users\TH.Liu> cd E:\python\Scripts\scikit-learn-0.22\scikit-learn-0.22 PS E:\python\Scripts\scikit-learn-0.22\scikit-learn-0.22> python setup.py install Partial import of sklearn during the build process. E:\python\lib\distutils\dist.py:274: UserWarning: Unknown distribution option: 'project_urls' warnings.warn(msg) E:\python\lib\distutils\dist.py:274: UserWarning: Unknown distribution option: 'python_requires' warnings.warn(msg) E:\python\lib\distutils\dist.py:274: UserWarning: Unknown distribution option: 'install_requires' warnings.warn(msg) No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils Traceback (most recent call last): File "setup.py", line 303, in <module> setup_package() File "setup.py", line 299, in setup_package setup(**metadata) File "E:\python\lib\site-packages\numpy\distutils\core.py", line 137, in setup config = configuration() File "setup.py", line 182, in configuration config.add_subpackage('sklearn') File "E:\python\lib\site-packages\numpy\distutils\misc_util.py", line 1035, in add_subpackage caller_level = 2) File "E:\python\lib\site-packages\numpy\distutils\misc_util.py", line 1004, in get_subpackage caller_level = caller_level + 1) File "E:\python\lib\site-packages\numpy\distutils\misc_util.py", line 941, in _get_configuration_from_setup_py config = setup_module.configuration(*args) File "sklearn\setup.py", line 86, in configuration cythonize_extensions(top_path, config) File "E:\python\Scripts\scikit-learn-0.22\scikit-learn-0.22\sklearn\_build_utils\__init__.py", line 50, in cythonize_extensions basic_check_build() File "E:\python\Scripts\scikit-learn-0.22\scikit-learn-0.22\sklearn\_build_utils\pre_build_helpers.py", line 70, in basic_check_build compile_test_program(code) File "E:\python\Scripts\scikit-learn-0.22\scikit-learn-0.22\sklearn\_build_utils\pre_build_helpers.py", line 40, in compile_test_program extra_postargs=extra_postargs) File "E:\python\lib\distutils\_msvccompiler.py", line 346, in compile self.initialize() File "E:\python\lib\distutils\_msvccompiler.py", line 239, in initialize vc_env = _get_vc_env(plat_spec) File "E:\python\lib\distutils\_msvccompiler.py", line 135, in _get_vc_env raise DistutilsPlatformError("Unable to find vcvarsall.bat") distutils.errors.DistutilsPlatformError: Unable to find vcvarsall.bat ``` 实际上,这俩错误我都在网上找过许多解决方式,但都没有用。下载了VS2010并尝试过在cmd中设置VS90COMNTOOLS =%VS100COMNTOOLS%,依然无效。 抱着最后的希望来这里求助……希望能得到解决。 ———————————————————— 2019.12.17 更新: 在安装了VS2015之后,vcvarsall.bat的问题消失了,剩下的只有: ``` E:\python\lib\distutils\dist.py:274: UserWarning: Unknown distribution option: 'project_urls' warnings.warn(msg) E:\python\lib\distutils\dist.py:274: UserWarning: Unknown distribution option: 'python_requires' warnings.warn(msg) E:\python\lib\distutils\dist.py:274: UserWarning: Unknown distribution option: 'install_requires' warnings.warn(msg) No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils ``` 这些问题了。 大家说PowerShell容易出BUG,我换用CMD后依旧如此。 我依旧没有找到这些报错的解决方案,希望得到大佬的帮助!
fatal error: boost/python/numpy.hpp: No such file or directory
哪个大神能解决这个问题,感激不尽!!! ``` fatal error: boost/python/numpy.hpp: No such file or directory ```
numpy.core.multiarray failed to import
# 问题: 使用cmd执行有import cv2 和 numpy的脚本会出现numpy.core.multiarray failed to import ![图片说明](https://img-ask.csdn.net/upload/201708/09/1502268358_642984.jpg) # 一些情况: **环境:** windows 10 python : 3.5.3 opencv-python: 3.3.0 numpy: 1.13.1 在**cmd**运行python,然后import 也会报错 ![图片说明](https://img-ask.csdn.net/upload/201708/09/1502268427_523346.jpg) numpy也是 ![图片说明](https://img-ask.csdn.net/upload/201708/09/1502268454_158067.jpg) **但是** 直接在cp里面是可以import cv2 和 numpy的, IDLE也可以跑程序(cmd里Python fliename.py失败的 ,用IDLE是可以运行的) # 采取过的措施 1. 重装numpy,opencv,乃至换过32位的Python(因为当时用64位的cmd进Python成功import过,但是并不能跑程序,后来还不行了) 2. pip install -U numpy (网上很多这个答案,其实没有用) 请问各路大神这个是什么原因,是环境变量的问题还是什么?
Windows下 sklearn:numpy.ufunc has the wrong size
各位大神求指点,我使用ArcGIS10.3自带的Python2.7.8(NumPy 1.7.1,matplotlib 1.3.0)自己去官网下载安装了scipy0.13.3和scikit-learn0.16.0,在编译scikit learn时出现numpy.dtype size问题,还没有运行其他代码,只是导入库就不行了: print('Hello World') # import numpy & scipy import numpy as np from numpy import linalg from numpy.linalg import norm from scipy.spatial.distance import squareform, pdist # import sklearn. import sklearn from sklearn.manifold import TSNE from sklearn.datasets import load_digits from sklearn.preprocessing import scale print "working" ![图片说明](https://img-ask.csdn.net/upload/201601/02/1451704594_425391.png) 新手跪求指点,万分感谢!
缺少 numpy.random.common
我使用python的tkinter编写了一个程序,用pyinstaller编译之后,程序提示 failed to execute script 文件名 错误提示: no module named 'numpy.random.common' 可是我重新pip numpy模块还是不好用 请问怎么解决? ``` #!/usr/bin/python # -- coding: utf-8 -- import fnmatch #选择文件的关键词 import os from time import sleep from tkinter import * import tkinter.filedialog #弹出选择路径的库 import tkinter.messagebox import fnmatch #选择文件的关键词 import re import pandas as pd import docx import pickle import codecs import string import shutil from win32com import client as wc def matchdocname(str1,root,i,list_box): if str1 in os.path.splitext(i)[0]: list_box.insert(END, root+"/"+i) def matchdoccontent(str1,root,i,list_box): if i.endswith('txt'): #当文件为txt时 with open(os.path.join(root, i) ,'r') as fp: errors='' aa=fp.read() if str1 in aa : list_box.insert(END, root+"/"+i) if i.endswith('xls') or i.endswith('xlsx') : #当文件为excel时 df=pd.read_excel(os.path.join(root, i)) df=df.values for k in df: for j in k: j=str(j) if str1 in j: list_box.insert(END, root+"/"+i) if i.endswith('docx'): #当文件为.docx时 word = wc.Dispatch('Word.Application') doc = word.Documents.Open(os.path.join(root, i)) newname=os.path.join(root, i)+"(translate txt)" doc.SaveAs(newname,4) doc.Close() word.Quit() with open(newname ,'r') as fp: errors='' aa=fp.read() if str1 in aa : list_box.insert(END, root+"/"+i) os.remove(newname) if i.endswith('doc'): #当文件为.doc时 word = wc.Dispatch('Word.Application') doc = word.Documents.Open(os.path.join(root, i)) newname=os.path.join(root, i)+"(translate txt)" doc.SaveAs(newname,4) doc.Close() word.Quit() with open(newname ,'r') as fp: errors='' aa=fp.read() if str1 in aa : list_box.insert(END, root+"/"+i) os.remove(newname) #删掉这个临时文件 def left(): if not entry.get() :#检测关键词输入框是否为空 tkinter.messagebox.showerror("提示信息:","出现以下错误:\n关键词不能为空")#弹出警告框 return #如果为空不再执行 if var1.get()==0 and var2.get()==0 : tkinter.messagebox.showerror("提示信息:","出现以下错误:\n匹配项不能为空")#弹出警告框 return #如果为空不再执行 list_box.delete(0,END) path = tkinter.filedialog.askdirectory()#弹出选择路径的窗口,path为获取的路径 path_list = os.walk(path)#获取一个列表目录的对象 for root, dirs, files in path_list: #print root, dirs, files if var1.get()==1 and var2.get()==0: #当只匹配文件名时 list_box.insert(END, '文件名') for i in files: matchdocname(entry.get(),root,i,list_box) elif var1.get()==0 and var2.get()==1: #当只匹配文件内容时 list_box.insert(END, '文件内容') for i in files: matchdoccontent(entry.get(),root,i,list_box) elif var1.get()==1 and var2.get()==1: #当既匹配文件名又匹配文件内容时 list_box.insert(END, '文件名') for i in files: matchdocname(entry.get(),root,i,list_box) list_box.insert(END, '--------------') list_box.insert(END, '文件内容') for i in files: matchdoccontent(entry.get(),root,i,list_box) def func2(e): if not list_box.curselection():#取双击的坐标52 return path = list_box.get(list_box.curselection(),last=None) os.startfile(path) def nagea(e): error = '' tdir = dirs.get(dirs.curselection()) if os.path.isfile(tdir): #如果是文件 则打开 os.startfile(tdir) elif os.path.isdir(tdir): #如果是文件夹 则调用dols setDirAndGo() def wenjianshu(): dirs.delete(0,END) path = tkinter.filedialog.askdirectory()#弹出选择路径的窗口,path为获取的路径 doLS1(path) #双击时调用,双击时,设置背景色为红色,并调用doLS函数打开所选文件 def setDirAndGo(ev=None): last = cwd.get() dirs.config(selectbackground='red') check = dirs.get(dirs.curselection()) if not check: check = os.curdir cwd.set(check) doLS() #实现更新目录的核心函数 def doLS(ev=None): error = '' tdir = cwd.get() if not tdir:tdir=os.curdir #若路径输入错误,或者打开的是文件,而不是目录,则更新错误提示信息 if not os.path.exists(tdir): error = os.getcwd()+'\\'+tdir + ':未找到文件' elif not os.path.isdir(tdir): error = os.getcwd()+'\\'+tdir + ':未找到目录' if error: cwd.set(error) top2.update() sleep(1) cwd.set(os.curdir) dirs.config(selectbackground='LightSkyBlue') top2.update() return cwd.set(os.getcwd()+'\\'+tdir) top2.update() dirlist = os.listdir(tdir)#os.listdir() 方法用于返回指定的文件夹包含的文件或文件夹的名字的列表。 dirlist.sort() os.chdir(tdir)#os.chdir() 方法用于改变当前工作目录到指定的路径。 #更新界面上方标签内容 dirl.config(text=os.getcwd()) top2.update() dirs.delete(0,END) dirs.insert(END,os.pardir)#os.chdir(os.pardir) 切换到上级目录 即将上级目录.. 插入到dirs对象中 #把选定目录的文件或文件夹的名字的列表依次插入到dirs对象中 for eachFile in dirlist: dirs.insert(END,eachFile) cwd.set(os.curdir) dirs.config(selectbackground='LightSkyBlue') def doLS1(tdir): error = '' if not tdir:tdir=os.curdir #若路径输入错误,或者打开的是文件,而不是目录,则更新错误提示信息 if not os.path.exists(tdir): error = os.getcwd()+'\\'+tdir + ':未找到文件' elif not os.path.isdir(tdir): error = os.getcwd()+'\\'+tdir + ':未找到目录' if error: cwd.set(error) top2.update() sleep(1) cwd.set(os.curdir) dirs.config(selectbackground='LightSkyBlue') top2.update() return cwd.set(os.getcwd()+'\\'+tdir) top2.update() dirlist = os.listdir(tdir)#os.listdir() 方法用于返回指定的文件夹包含的文件或文件夹的名字的列表。 dirlist.sort os.chdir(tdir)#os.chdir() 方法用于改变当前工作目录到指定的路径。 #更新界面上方标签内容 dirl.config(text=os.getcwd()) top2.update() dirs.delete(0,END) dirs.insert(END,os.pardir)#os.chdir(os.pardir) 切换到上级目录 即将上级目录.. 插入到dirs对象中 #把选定目录的文件或文件夹的名字的列表依次插入到dirs对象中 for eachFile in dirlist: dirs.insert(END,eachFile) cwd.set(os.curdir) dirs.config(selectbackground='LightSkyBlue') top2 = Tk() top2.title('营销集约管控中心-文件管理') top2.geometry('+50+50')#窗口大小,窗口位置 cwd = StringVar(top2) var=IntVar() dirl = Label(top2,fg = 'BLUE',font = ('Helvetica',18,'bold')) dirl.pack() dirfm = Frame(top2) dirs = Listbox(dirfm,height=25,width=90) #通过使用List的bind()方法,将鼠标双击事件绑定,并调用setDirAndGo函数 dirs.bind('<Double-1>',nagea) dirs.pack(side=LEFT,fill=BOTH) list_box = Listbox(dirfm,height=25,width=90) list_box.bind('<Double-Button-1>',func2) #绑定一个双击触发事件 list_box.pack(side=LEFT,fill=BOTH)#显示列表框 dirfm.pack() #第二个框架bfm,放置按钮 bfm = Frame(top2) open1 = Button(bfm,text='文件树',command=wenjianshu,activeforeground='white',activebackground='blue') open1.pack(side=LEFT) bfm.pack(side=LEFT,fill=BOTH) #多选框插件 var1 = tkinter.IntVar() # 用来储存下面勾选项1中返回的0或1 var2 = tkinter.IntVar() # 用来储存下面勾选项2中返回的0或1 button2=tkinter.Checkbutton(top2,text="匹配文件内容",variable=var2,onvalue=1,offvalue=0) button2.pack(side=RIGHT,fill=BOTH) button1=tkinter.Checkbutton(top2,text="匹配文件名",variable=var1,onvalue=1,offvalue=0) button1.pack(side=RIGHT,fill=BOTH) #按钮控件 entry = Entry()#输入框实例化 entry.pack(side=RIGHT,fill=BOTH)#输入框 button2=Button(top2,text="关键字",command=left) button2.pack(side=RIGHT,fill=BOTH) if __name__ =='__main__': #设定初始目录为桌面 mainloop() ```
keras中model.evaluate()报错:'numpy.float64' object is not iterable
``` x_train, x_test, y_train, y_test = train_test_split(x_data, y_data, test_size=0.25) mean = x_train.mean(axis=0) std = x_train.std(axis=0) train_data = (x_train - mean) / std test_data = (x_test - mean) / std model = Sequential([Dense(64, input_shape=(6,)), Activation('relu'), Dense(32), Activation('relu'), Dense(1)]) sgd = keras.optimizers.SGD(lr=0.01, decay=1e-6, momentum=0.9, nesterov=True) model.compile(loss='mean_squared_error', optimizer=sgd) k = model.fit [loss, sgd] = model.evaluate(test_data, y_test, verbose=1) ``` 最后一步不知道哪出了问题。。test_data, y_test都是dataframe啊 TypeError Traceback (most recent call last) <ipython-input-29-3b0767a3c446> in <module> ----> 1 [loss, mse] = model.evaluate(test_data, y_test, verbose=1) TypeError: 'numpy.float64' object is not iterable
如何解决numpy.ndarray' object is not callable
我用python进行非线性规划时报错numpy.ndarray' object is not callable,有大佬可以帮忙解释一下吗 直到最后一句res=minimize。。。才报错,之前检查过都没有问题 ``` from scipy.optimize import minimize import numpy as np def fun(): v=lambda x:abs((x(1)+0*x(2)+0*x(3)+0*x(4)+0*x(5)+0*x(6)+0*x(7)+0*x(8)+0*x(9)+0*x(10)+0*x(11)+0*x(12)+0*x(13)+0*x(14))) return v def cons(): # d,e=args con=({'type':'eq','fun':lambda x: x(1)-(2171.4/0.85*x(2))}, {'type': 'eq', 'fun': lambda x: (x(5)*x(6)*89.496/6.28)-x(7)-x(8)}, {'type': 'eq', 'fun': lambda x: x(9)*x(10)-x(10)*x(11)-x(8)*x(11)}, {'type': 'eq', 'fun': lambda x: x(12) - x(13)+x(11)}, {'type': 'eq', 'fun': lambda x: x(10) - 12500*3.1415}, {'type': 'ineq', 'fun': lambda x: x(6) - x(14)}, {'type': 'ineq', 'fun': lambda x: x(3) - x(4)-2.45}, {'type': 'eq', 'fun': lambda x: x(14) - 12.14*3.1415}, {'type': 'ineq', 'fun': lambda x: x(4) - 2.45}, {'type': 'ineq', 'fun': lambda x: 97.55 - x(4)}, {'type': 'ineq', 'fun': lambda x: x(3) }, {'type': 'ineq', 'fun': lambda x: 95.1 - x(3)}, {'type': 'ineq', 'fun': lambda x: x(5)-2.45-x(4)}, {'type': 'ineq', 'fun': lambda x: 100-x(5)} ) return con a=fun() b=cons() # print(b) x0=np.asarray([3,4,3,2,3,4,3,2,3,4,3,2,3,2]) bounds=((0,None),(0,None),(0,None),(0,None),(0,None),(0,None),(0,None),(0,None),(0,None),(0,None),(0,None),(0,None),(0,None),(0,None)) res=minimize(a,x0,method='SLSQP',constraints=b,bounds=bounds) print(res) print(b) ```
pyinstaller打包处理的程序用不了
warn-xxx.txt文件的信息如下,求大佬处理 This file lists modules PyInstaller was not able to find. This does not necessarily mean this module is required for running you program. Python and Python 3rd-party packages include a lot of conditional or optional module. For example the module 'ntpath' only exists on Windows, whereas the module 'posixpath' only exists on Posix systems. Types if import: * top-level: imported at the top-level - look at these first * conditional: imported within an if-statement * delayed: imported from within a function * optional: imported within a try-except-statement IMPORTANT: Do NOT post this list to the issue-tracker. Use it as a basis for yourself tracking down the missing module. Thanks! missing module named pyimod03_importers - imported by PyInstaller.loader.pyimod02_archive (delayed, conditional), c:\program files\python37\lib\site-packages\PyInstaller\loader\rthooks\pyi_rth_pkgres.py (top-level) missing module named 'pkg_resources.extern.pyparsing' - imported by pkg_resources._vendor.packaging.requirements (top-level), pkg_resources._vendor.packaging.markers (top-level) missing module named 'com.sun' - imported by pkg_resources._vendor.appdirs (delayed, conditional, optional) missing module named com - imported by pkg_resources._vendor.appdirs (delayed) missing module named win32api - imported by distutils.msvccompiler (optional), pkg_resources._vendor.appdirs (delayed, conditional, optional) missing module named win32com.shell - imported by pkg_resources._vendor.appdirs (delayed, conditional, optional) missing module named _uuid - imported by uuid (optional) missing module named netbios - imported by uuid (delayed) missing module named win32wnet - imported by uuid (delayed) missing module named __builtin__ - imported by numpy.core.numerictypes (conditional), numpy.core.numeric (conditional), numpy.lib.function_base (conditional), numpy.lib._iotools (conditional), numpy.ma.core (conditional), numpy.distutils.misc_util (delayed, conditional), numpy (conditional), pymysql._compat (conditional), pkg_resources._vendor.pyparsing (conditional), setuptools._vendor.pyparsing (conditional) missing module named ordereddict - imported by pkg_resources._vendor.pyparsing (optional), setuptools._vendor.pyparsing (optional) missing module named StringIO - imported by PyInstaller.lib.modulegraph._compat (conditional), PyInstaller.lib.modulegraph.zipio (conditional), setuptools._vendor.six (conditional), numpy.lib.utils (delayed, conditional), numpy.lib.format (delayed, conditional), numpy.testing._private.utils (conditional), six (conditional), urllib3.packages.six (conditional), requests.compat (conditional), selenium.webdriver.remote.webelement (optional), pkg_resources._vendor.six (conditional) missing module named _scproxy - imported by urllib.request (conditional) missing module named 'macholib.MachO' - imported by PyInstaller.depend.dylib (delayed), PyInstaller.depend.bindepend (delayed), PyInstaller.utils.osx (top-level) missing module named macholib - imported by PyInstaller.depend.dylib (delayed, conditional) missing module named _pkgutil - imported by PyInstaller.lib.modulegraph.modulegraph (delayed, optional) missing module named dis3 - imported by PyInstaller.lib.modulegraph._compat (conditional) missing module named urllib.pathname2url - imported by urllib (conditional), PyInstaller.lib.modulegraph._compat (conditional) missing module named pyimod00_crypto_key - imported by PyInstaller.loader.pyimod02_archive (delayed, optional) missing module named thread - imported by numpy.core.arrayprint (conditional, optional), PyInstaller.loader.pyimod02_archive (conditional) missing module named 'macholib.dyld' - imported by PyInstaller.depend.bindepend (delayed) missing module named 'macholib.mach_o' - imported by PyInstaller.depend.bindepend (delayed) missing module named Crypto - imported by PyInstaller.building.makespec (delayed, conditional, optional) missing module named win32ctypes.core._time - imported by win32ctypes.core (top-level), win32ctypes.pywin32.win32api (top-level) missing module named win32ctypes.core._system_information - imported by win32ctypes.core (top-level), win32ctypes.pywin32.win32api (top-level) missing module named win32ctypes.core._resource - imported by win32ctypes.core (top-level), win32ctypes.pywin32.win32api (top-level) missing module named win32ctypes.core._dll - imported by win32ctypes.core (top-level), win32ctypes.pywin32.win32api (top-level) missing module named win32ctypes.core._common - imported by win32ctypes.core (top-level), win32ctypes.pywin32.win32api (top-level), win32ctypes.pywin32.win32cred (top-level) missing module named win32ctypes.core._authentication - imported by win32ctypes.core (top-level), win32ctypes.pywin32.win32cred (top-level) missing module named cffi - imported by win32ctypes.core (optional) missing module named UserDict - imported by PyInstaller.compat (conditional), pytz.lazy (optional) missing module named multiprocessing.set_start_method - imported by multiprocessing (top-level), multiprocessing.spawn (top-level) missing module named multiprocessing.get_start_method - imported by multiprocessing (top-level), multiprocessing.spawn (top-level) missing module named multiprocessing.TimeoutError - imported by multiprocessing (top-level), multiprocessing.pool (top-level) missing module named multiprocessing.get_context - imported by multiprocessing (top-level), multiprocessing.pool (top-level), multiprocessing.managers (top-level), multiprocessing.sharedctypes (top-level) missing module named multiprocessing.BufferTooShort - imported by multiprocessing (top-level), multiprocessing.connection (top-level) missing module named multiprocessing.AuthenticationError - imported by multiprocessing (top-level), multiprocessing.connection (top-level) missing module named pkg_resources.extern.packaging - imported by pkg_resources.extern (top-level), pkg_resources (top-level) missing module named pkg_resources.extern.appdirs - imported by pkg_resources.extern (top-level), pkg_resources (top-level) missing module named 'pkg_resources.extern.six.moves' - imported by pkg_resources (top-level), pkg_resources._vendor.packaging.requirements (top-level) missing module named pkg_resources.extern.six - imported by pkg_resources.extern (top-level), pkg_resources (top-level) missing module named 'multiprocessing.forking' - imported by c:\program files\python37\lib\site-packages\PyInstaller\loader\rthooks\pyi_rth_multiprocessing.py (optional) missing module named resource - imported by posix (top-level), E:\yxrj\dingzhi\cj\231.py (top-level) missing module named posix - imported by os (conditional, optional), E:\yxrj\dingzhi\cj\231.py (top-level) missing module named _posixsubprocess - imported by subprocess (conditional), multiprocessing.util (delayed), E:\yxrj\dingzhi\cj\231.py (top-level) missing module named readline - imported by cmd (delayed, conditional, optional), code (delayed, conditional, optional), pdb (delayed, optional), E:\yxrj\dingzhi\cj\231.py (top-level) excluded module named _frozen_importlib - imported by importlib (optional), importlib.abc (optional), PyInstaller.loader.pyimod02_archive (delayed, conditional), E:\yxrj\dingzhi\cj\231.py (top-level) missing module named _frozen_importlib_external - imported by importlib._bootstrap (delayed), importlib (optional), importlib.abc (optional), E:\yxrj\dingzhi\cj\231.py (top-level) missing module named _winreg - imported by platform (delayed, optional), numpy.distutils.cpuinfo (delayed, conditional, optional), requests.utils (delayed, conditional, optional), selenium.webdriver.firefox.firefox_binary (delayed, optional), E:\yxrj\dingzhi\cj\231.py (top-level), pkg_resources._vendor.appdirs (delayed) missing module named java - imported by platform (delayed), E:\yxrj\dingzhi\cj\231.py (top-level) missing module named 'java.lang' - imported by platform (delayed, optional), xml.sax._exceptions (conditional), E:\yxrj\dingzhi\cj\231.py (top-level) missing module named vms_lib - imported by platform (delayed, conditional, optional), E:\yxrj\dingzhi\cj\231.py (top-level) missing module named termios - imported by tty (top-level), getpass (optional), E:\yxrj\dingzhi\cj\231.py (top-level) missing module named urllib.getproxies_environment - imported by urllib (conditional), requests.compat (conditional) missing module named urllib.proxy_bypass_environment - imported by urllib (conditional), requests.compat (conditional) missing module named urllib.proxy_bypass - imported by urllib (conditional), requests.compat (conditional) missing module named urllib.getproxies - imported by urllib (conditional), requests.compat (conditional) missing module named urllib.unquote_plus - imported by urllib (conditional), requests.compat (conditional) missing module named urllib.quote_plus - imported by urllib (conditional), requests.compat (conditional) missing module named urllib.unquote - imported by urllib (conditional), requests.compat (conditional) missing module named urllib.urlencode - imported by urllib (optional), urllib3.packages.rfc3986.compat (optional), requests.compat (conditional) missing module named urllib.quote - imported by urllib (optional), urllib3.packages.rfc3986.compat (optional), requests.compat (conditional) missing module named grp - imported by shutil (optional), tarfile (optional), pathlib (delayed), distutils.archive_util (optional), E:\yxrj\dingzhi\cj\231.py (top-level) missing module named 'org.python' - imported by pickle (optional), xml.sax (delayed, conditional), setuptools.sandbox (conditional), E:\yxrj\dingzhi\cj\231.py (top-level) missing module named org - imported by copy (optional), E:\yxrj\dingzhi\cj\231.py (top-level) missing module named pwd - imported by posixpath (delayed, conditional), shutil (optional), tarfile (optional), http.server (delayed, optional), webbrowser (delayed), pathlib (delayed, conditional, optional), distutils.util (delayed, conditional), distutils.archive_util (optional), netrc (delayed, conditional), getpass (delayed), E:\yxrj\dingzhi\cj\231.py (top-level) missing module named urllib2 - imported by numpy.lib._datasource (delayed, conditional), requests.compat (conditional), selenium.webdriver.common.utils (delayed, optional), selenium.webdriver.common.service (delayed, optional) missing module named urlparse - imported by numpy.lib._datasource (delayed, conditional), requests.compat (conditional), selenium.webdriver.remote.remote_connection (optional) runtime module named urllib3.packages.six.moves - imported by http.client (top-level), urllib3.connectionpool (top-level), urllib3.util.response (top-level), 'urllib3.packages.six.moves.urllib' (top-level), urllib3.response (top-level), urllib3.util.queue (top-level) missing module named 'OpenSSL.crypto' - imported by urllib3.contrib.pyopenssl (delayed) missing module named 'cryptography.x509' - imported by urllib3.contrib.pyopenssl (delayed, optional) missing module named 'cryptography.hazmat' - imported by pymysql._auth (optional), urllib3.contrib.pyopenssl (top-level) missing module named cryptography - imported by pymysql._auth (optional), urllib3.contrib.pyopenssl (top-level), requests (optional) missing module named OpenSSL - imported by urllib3.contrib.pyopenssl (top-level) missing module named 'backports.ssl_match_hostname' - imported by setuptools.ssl_support (optional), urllib3.packages.ssl_match_hostname (optional) missing module named brotli - imported by urllib3.util.request (optional), urllib3.response (optional) missing module named "'urllib3.packages.six.moves.urllib'.parse" - imported by urllib3.request (top-level), urllib3.poolmanager (top-level) missing module named Queue - imported by urllib3.util.queue (conditional) missing module named httplib - imported by selenium.webdriver.safari.webdriver (optional), selenium.webdriver.blackberry.webdriver (optional), selenium.webdriver.webkitgtk.webdriver (optional) missing module named cStringIO - imported by selenium.webdriver.firefox.firefox_profile (optional) missing module named copy_reg - imported by numpy.core (conditional), soupsieve.util (conditional), cStringIO (top-level) missing module named 'backports.functools_lru_cache' - imported by soupsieve.util (conditional) missing module named iconv_codec - imported by bs4.dammit (optional) missing module named cchardet - imported by bs4.dammit (optional) missing module named lxml - imported by bs4.builder._lxml (top-level) missing module named 'html5lib.treebuilders' - imported by bs4.builder._html5lib (optional) missing module named 'html5lib.constants' - imported by bs4.builder._html5lib (top-level) missing module named html5lib - imported by bs4.builder._html5lib (top-level) missing module named Cookie - imported by requests.compat (conditional) missing module named cookielib - imported by requests.compat (conditional) missing module named simplejson - imported by pandas.util._print_versions (delayed, conditional, optional), requests.compat (optional) missing module named socks - imported by urllib3.contrib.socks (optional) missing module named _dummy_threading - imported by dummy_threading (optional) missing module named ConfigParser - imported by numpy.distutils.system_info (conditional), numpy.distutils.npy_pkg_config (conditional), pymysql.optionfile (conditional) missing module named scipy - imported by numpy.testing._private.nosetester (delayed, conditional), pandas.core.missing (delayed) missing module named numexpr - imported by pandas.core.computation.expressions (conditional), pandas.core.computation.engines (delayed) missing module named 'scipy.stats' - imported by pandas.plotting._matplotlib.hist (delayed), pandas.plotting._matplotlib.misc (delayed, conditional), pandas.core.nanops (delayed, conditional) missing module named 'scipy.signal' - imported by pandas.core.window (delayed, conditional) missing module named commands - imported by numpy.distutils.cpuinfo (conditional) missing module named setuptools.extern.packaging - imported by setuptools.extern (top-level), setuptools.dist (top-level), setuptools.command.egg_info (top-level) missing module named 'setuptools.extern.six' - imported by setuptools (top-level), setuptools.extension (top-level) missing module named setuptools.extern.six.moves.filterfalse - imported by setuptools.extern.six.moves (top-level), setuptools.dist (top-level), setuptools.msvc (top-level) missing module named setuptools.extern.six.moves.filter - imported by setuptools.extern.six.moves (top-level), setuptools.dist (top-level), setuptools.ssl_support (top-level), setuptools.command.py36compat (top-level) missing module named _manylinux - imported by setuptools.pep425tags (delayed, optional) missing module named wincertstore - imported by setuptools.ssl_support (delayed, optional) missing module named backports - imported by setuptools.ssl_support (optional) missing module named 'setuptools._vendor.six.moves' - imported by 'setuptools._vendor.six.moves' (top-level) missing module named 'setuptools.extern.pyparsing' - imported by setuptools._vendor.packaging.requirements (top-level), setuptools._vendor.packaging.markers (top-level) missing module named 'setuptools.extern.packaging.version' - imported by setuptools.msvc (top-level) missing module named setuptools.extern.six.moves.map - imported by setuptools.extern.six.moves (top-level), setuptools.dist (top-level), setuptools.command.easy_install (top-level), setuptools.sandbox (top-level), setuptools.package_index (top-level), setuptools.ssl_support (top-level), setuptools.command.egg_info (top-level), setuptools.namespaces (top-level) runtime module named setuptools.extern.six.moves - imported by setuptools.dist (top-level), setuptools.py33compat (top-level), setuptools.command.easy_install (top-level), setuptools.sandbox (top-level), setuptools.command.setopt (top-level), setuptools.package_index (top-level), setuptools.ssl_support (top-level), setuptools.command.egg_info (top-level), setuptools.command.py36compat (top-level), setuptools.namespaces (top-level), setuptools.msvc (top-level), 'setuptools._vendor.six.moves' (top-level) missing module named setuptools.extern.six - imported by setuptools.extern (top-level), setuptools.monkey (top-level), setuptools.dist (top-level), setuptools.extern.six.moves (top-level), setuptools.py33compat (top-level), setuptools.config (top-level), setuptools.command.easy_install (top-level), setuptools.sandbox (top-level), setuptools.py27compat (top-level), setuptools.package_index (top-level), setuptools.wheel (top-level), setuptools.command.egg_info (top-level), setuptools.command.sdist (top-level), setuptools.command.bdist_egg (top-level), setuptools.unicode_utils (top-level), setuptools.glob (top-level), setuptools.command.develop (top-level) missing module named 'numpy_distutils.cpuinfo' - imported by numpy.f2py.diagnose (delayed, conditional, optional) missing module named 'numpy_distutils.fcompiler' - imported by numpy.f2py.diagnose (delayed, conditional, optional) missing module named 'numpy_distutils.command' - imported by numpy.f2py.diagnose (delayed, conditional, optional) missing module named numpy_distutils - imported by numpy.f2py.diagnose (delayed, optional) missing module named 'nose.plugins' - imported by numpy.testing._private.noseclasses (top-level), numpy.testing._private.nosetester (delayed) missing module named numpy.core.number - imported by numpy.core (delayed), numpy.testing._private.utils (delayed) missing module named numpy.core.signbit - imported by numpy.core (delayed), numpy.testing._private.utils (delayed) missing module named numpy.core.float64 - imported by numpy.core (delayed), numpy.testing._private.utils (delayed) missing module named numpy.core.integer - imported by numpy.core (top-level), numpy.fft.helper (top-level) missing module named numpy.core.conjugate - imported by numpy.core (top-level), numpy.fft.pocketfft (top-level) missing module named numpy.core.sign - imported by numpy.core (top-level), numpy.linalg.linalg (top-level) missing module named numpy.core.divide - imported by numpy.core (top-level), numpy.linalg.linalg (top-level) missing module named numpy.core.object_ - imported by numpy.core (top-level), numpy.linalg.linalg (top-level) missing module named numpy.core.geterrobj - imported by numpy.core (top-level), numpy.linalg.linalg (top-level) missing module named numpy.core.sqrt - imported by numpy.core (top-level), numpy.linalg.linalg (top-level), numpy.fft.pocketfft (top-level) missing module named numpy.core.add - imported by numpy.core (top-level), numpy.linalg.linalg (top-level) missing module named numpy.core.complexfloating - imported by numpy.core (top-level), numpy.linalg.linalg (top-level) missing module named numpy.core.inexact - imported by numpy.core (top-level), numpy.linalg.linalg (top-level) missing module named numpy.core.cdouble - imported by numpy.core (top-level), numpy.linalg.linalg (top-level) missing module named numpy.core.csingle - imported by numpy.core (top-level), numpy.linalg.linalg (top-level) missing module named numpy.core.double - imported by numpy.core (top-level), numpy.linalg.linalg (top-level) missing module named numpy.core.single - imported by numpy.core (top-level), numpy.linalg.linalg (top-level) missing module named numpy.core.float32 - imported by numpy.core (top-level), numpy.testing._private.utils (top-level) missing module named numpy.core.intp - imported by numpy.core (top-level), numpy.testing._private.utils (top-level), numpy.linalg.linalg (top-level) missing module named numpy.eye - imported by numpy (delayed), numpy.core.numeric (delayed) missing module named dummy_thread - imported by numpy.core.arrayprint (conditional, optional) missing module named 'nose.util' - imported by numpy.testing._private.noseclasses (top-level) missing module named nose - imported by numpy.testing._private.utils (delayed, optional), numpy.testing._private.decorators (delayed), numpy.testing._private.noseclasses (top-level) missing module named win32pdh - imported by numpy.testing._private.utils (delayed, conditional) missing module named __svn_version__ - imported by numpy.f2py.__version__ (optional) missing module named numarray - imported by numpy.distutils.system_info (delayed, conditional, optional) missing module named Numeric - imported by numpy.distutils.system_info (delayed, conditional, optional) missing module named win32con - imported by distutils.msvccompiler (optional) missing module named _curses - imported by curses (top-level), curses.has_key (top-level) missing module named pytest - imported by numpy._pytesttester (delayed), pandas.util._tester (delayed, optional), pandas.util.testing (delayed, conditional, optional) missing module named future_builtins - imported by numpy.lib.npyio (conditional) missing module named cpickle - imported by numpy.compat.py3k (conditional) missing module named pickle5 - imported by numpy.compat.py3k (conditional, optional) missing module named numpy.histogramdd - imported by numpy (delayed), numpy.lib.twodim_base (delayed) missing module named numpy.lib.i0 - imported by numpy.lib (top-level), numpy.dual (top-level) missing module named 'scipy.sparse' - imported by pandas.core.sparse.scipy_sparse (delayed), pandas.core.arrays.sparse (delayed), pandas.core.dtypes.common (delayed, conditional, optional) missing module named botocore - imported by pandas.io.s3 (delayed) missing module named 'pyarrow.parquet' - imported by pandas.io.parquet (delayed) missing module named pyarrow - imported by pandas.io.feather_format (delayed) missing module named contextmanager - imported by dateutil.tz.tz (optional) runtime module named six.moves - imported by dateutil.tz.tz (top-level), dateutil.tz.win (top-level), dateutil.rrule (top-level) missing module named six.moves.range - imported by six.moves (top-level), dateutil.rrule (top-level) missing module named dateutil.tz.tzfile - imported by dateutil.tz (top-level), dateutil.zoneinfo (top-level) missing module named dateutil.tz.tzlocal - imported by dateutil.tz (top-level), dateutil.rrule (top-level) missing module named dateutil.tz.tzutc - imported by dateutil.tz (top-level), dateutil.rrule (top-level) missing module named PyQt4 - imported by pandas.io.clipboard.clipboards (delayed, optional), pandas.io.clipboard (delayed, conditional, optional) missing module named PyQt5 - imported by pandas.io.clipboard.clipboards (delayed, optional), pandas.io.clipboard (delayed, conditional, optional) missing module named qtpy - imported by pandas.io.clipboard.clipboards (delayed, optional), pandas.io.clipboard (delayed, conditional, optional) missing module named 'sqlalchemy.types' - imported by pandas.io.sql (delayed, conditional) missing module named 'sqlalchemy.schema' - imported by pandas.io.sql (delayed, conditional) missing module named sqlalchemy - imported by pandas.io.sql (delayed, conditional, optional) missing module named tables - imported by pandas.io.pytables (delayed, conditional) missing module named xlwt - imported by pandas.io.excel._xlwt (delayed) missing module named xlsxwriter - imported by pandas.io.excel._xlsxwriter (delayed) missing module named 'openpyxl.styles' - imported by pandas.io.excel._openpyxl (delayed) missing module named 'openpyxl.style' - imported by pandas.io.excel._openpyxl (delayed) missing module named openpyxl - imported by pandas.io.excel._openpyxl (delayed, conditional) missing module named xlrd - imported by pandas.io.excel._xlrd (delayed) missing module named 'odf.namespaces' - imported by pandas.io.excel._odfreader (delayed) missing module named 'odf.table' - imported by pandas.io.excel._odfreader (delayed) missing module named 'odf.opendocument' - imported by pandas.io.excel._odfreader (delayed) missing module named odf - imported by pandas.io.excel._odfreader (delayed) missing module named matplotlib - imported by pandas.plotting._matplotlib.boxplot (top-level), pandas.plotting._matplotlib.compat (delayed, optional), pandas.plotting._matplotlib.timeseries (delayed), pandas.plotting._matplotlib.core (delayed), pandas.io.formats.style (optional) missing module named 'matplotlib.pyplot' - imported by pandas.plotting._matplotlib.style (delayed), pandas.plotting._matplotlib.tools (delayed), pandas.plotting._matplotlib.core (delayed), pandas.plotting._matplotlib.timeseries (delayed), pandas.plotting._matplotlib.boxplot (delayed), pandas.plotting._matplotlib.hist (delayed), pandas.plotting._matplotlib.misc (delayed), pandas.plotting._matplotlib (delayed), pandas.io.formats.style (optional), pandas.util.testing (delayed) missing module named numpy.array - imported by numpy (top-level), numpy.ma.core (top-level), numpy.ma.extras (top-level), numpy.ma.mrecords (top-level), numpy.ctypeslib (top-level) missing module named numpy.recarray - imported by numpy (top-level), numpy.ma.mrecords (top-level) missing module named numpy.ndarray - imported by numpy (top-level), numpy.ma.core (top-level), numpy.ma.extras (top-level), numpy.ma.mrecords (top-level), numpy.ctypeslib (top-level), pandas.compat.numpy.function (top-level) missing module named numpy.dtype - imported by numpy (top-level), numpy.ma.mrecords (top-level), numpy.ctypeslib (top-level) missing module named numpy.bool_ - imported by numpy (top-level), numpy.ma.core (top-level), numpy.ma.mrecords (top-level) missing module named 'matplotlib.ticker' - imported by pandas.plotting._matplotlib.converter (top-level), pandas.plotting._matplotlib.tools (top-level), pandas.plotting._matplotlib.core (delayed) missing module named 'matplotlib.table' - imported by pandas.plotting._matplotlib.tools (top-level) missing module named 'matplotlib.colors' - imported by pandas.plotting._matplotlib.style (top-level) missing module named 'matplotlib.cm' - imported by pandas.plotting._matplotlib.style (top-level) missing module named 'matplotlib.patches' - imported by pandas.plotting._matplotlib.misc (top-level) missing module named 'matplotlib.lines' - imported by pandas.plotting._matplotlib.misc (top-level) missing module named 'matplotlib.axes' - imported by pandas.plotting._matplotlib.core (delayed) missing module named 'matplotlib.units' - imported by pandas.plotting._matplotlib.converter (top-level) missing module named 'matplotlib.transforms' - imported by pandas.plotting._matplotlib.converter (top-level) missing module named 'matplotlib.dates' - imported by pandas.plotting._matplotlib.converter (top-level) missing module named numpy.expand_dims - imported by numpy (top-level), numpy.ma.core (top-level) missing module named numpy.iscomplexobj - imported by numpy (top-level), numpy.ma.core (top-level) missing module named numpy.amin - imported by numpy (top-level), numpy.ma.core (top-level) missing module named numpy.amax - imported by numpy (top-level), numpy.ma.core (top-level) missing module named 'IPython.core' - imported by pandas.io.formats.printing (delayed, conditional) missing module named IPython - imported by pandas.io.formats.printing (delayed) missing module named s3fs - imported by pandas.io.common (delayed, optional) missing module named sets - imported by pytz.tzinfo (optional) missing module named numpy.random.randn - imported by numpy.random (top-level), pandas.util.testing (top-level) missing module named numpy.random.rand - imported by numpy.random (top-level), pandas.util.testing (top-level) missing module named hypothesis - imported by pandas.util._tester (delayed, optional) missing module named 'lxml.etree' - imported by pandas.io.html (delayed) missing module named 'lxml.html' - imported by pandas.io.html (delayed)
python出现 'numpy.dtype' object has no attribute 'is_floating'
模型进行训练的时候在优化器运行部分出现了 'numpy.dtype' object has no attribute 'is_floating' ``` <ipython-input-1-12256e71d6bc> in <module> 260 print('\nPCC training') 261 start = time.time() --> 262 source_acc, target_acc = train_and_evaluate('pcc') 263 sio.savemat('PCC1.mat',{'a':target_y}) 264 end = time.time() <ipython-input-1-12256e71d6bc> in train_and_evaluate(training_mode, num_steps, verbose) 221 y = np.vstack([y0, y1]) 222 pred_loss, coral_loss, cycle_loss, total_loss, classify_labels, pred= loss_function(Fmodel,X,y,True) --> 223 pcc_train_op = tf.train.MomentumOptimizer(learning_rate, 0.9).minimize(lambda:total_loss) 224 #Evaluation 225 correct_label_pred = tf.equal(tf.argmax(classify_labels, 1),tf.argmax(pred_labels,1)) ~/anaconda3/envs/alex/lib/python3.6/site-packages/tensorflow/python/training/optimizer.py in minimize(self, loss, global_step, var_list, gate_gradients, aggregation_method, colocate_gradients_with_ops, name, grad_loss) 401 aggregation_method=aggregation_method, 402 colocate_gradients_with_ops=colocate_gradients_with_ops, --> 403 grad_loss=grad_loss) 404 405 vars_with_grad = [v for g, v in grads_and_vars if g is not None] ~/anaconda3/envs/alex/lib/python3.6/site-packages/tensorflow/python/training/optimizer.py in compute_gradients(self, loss, var_list, gate_gradients, aggregation_method, colocate_gradients_with_ops, grad_loss) 473 # to be executed. 474 with ops.control_dependencies([loss_value]): --> 475 grads = tape.gradient(loss_value, var_list, grad_loss) 476 return list(zip(grads, var_list)) 477 ~/anaconda3/envs/alex/lib/python3.6/site-packages/tensorflow/python/eager/backprop.py in gradient(self, target, sources, output_gradients, unconnected_gradients) 948 flat_targets = [] 949 for t in nest.flatten(target): --> 950 if not t.dtype.is_floating: 951 logging.vlog( 952 logging.WARN, "The dtype of the target tensor must be " AttributeError: 'numpy.dtype' object has no attribute 'is_floating' ``` 一直解决不了
numpy.array()打开图片时像素点表示问题
在应用numpy.array()打开图片 代码如下: ``` i = Image.open('images/numbers/0.1.png') iar = np.array(i, dtype='int64') print(iar) ``` 输出结果中大部分为 [[[255 255 255 255] ...... (即alpha数值有表示出来) 而另一张图片,可能就会输出 [[[255 255 255] ...... (即alpha数值没有表示出来) 想请教一下这是为什么呢,有没有什么办法可以把它们统一起来吗?
numpy.ndarray' object has no attribute 'show'
已安装:matplotlib,pyparsing,numpy,scipy 源代码: #!/usr/bin/env python # -*- coding:utf-8 -*- from PIL import Image from pylab import* im=array(Image.open('c:\\Python27\\tiananmen.jpg')) im.show() x=[100,100,400,400] y=[200,500,200,500] plot(x,y,'r*') #使用红色星状标记绘制点 plot(x[:2],y[:2])#绘制连接前两个点的线 title('Plotting:"tiananmen.jpg"') #添加标题
Pycuda中gpuarray.to_gpu能向共享GPU内存中申请空间吗
GPU信息 ![GPU信息](https://img-ask.csdn.net/upload/202001/06/1578293738_135954.png) ![GPU信息](https://img-ask.csdn.net/upload/202001/06/1578293671_541491.png) --------------------------------------------- 运行如下代码 比较两个矩阵,取最大值为一个新矩阵 ``` import pycuda.driver as drv import pycuda.autoinit import numpy import numpy.linalg as la from pycuda import driver, compiler, gpuarray, tools from pycuda.compiler import SourceModule import os if (os.system("cl.exe")): os.environ['PATH'] += ';'+r"C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\bin\\amd64\\" if (os.system("cl.exe")): raise RuntimeError("cl.exe still not found, path probably incorrect") a = numpy.random.randint(0,3,(23600,26919)).astype(numpy.float32) b = numpy.random.randint(1,4,(23600,26919)).astype(numpy.float32) a_gpu = gpuarray.to_gpu(a) b_gpu = gpuarray.to_gpu(b) result_array_GPU = gpuarray.maximum(a_gpu,b_gpu) print(a_gpu.get()) print(b_gpu.get()) print(result_array_GPU,type(result_array_GPU.get())) ``` --- 出现错误 out of memory ![图片说明](https://img-ask.csdn.net/upload/202001/06/1578293792_715378.png) --- 查看GPU性能,发现_**共享GPU内存**_还有空间,请问能利用这一块内存吗?如何利用这一块的内存呢 ![图片说明](https://img-ask.csdn.net/upload/202001/06/1578293948_284767.png) ---- 网上看说可以去BOIS总结去设置大小,也有的说当专有GPU内存不够会向共享自动申请 具体我还要怎么操作呢,还请不吝赐教
请教朋友们,python中numpy.min(dataset[:,j]) 这句话是什么意思?
各位大神好,问题是这样的: 最近在看K-means聚类算法的python实现版本,看到了一个朋友写的程序,下面是选取数据集dataSet的k个初始中心的函数 ``` 各位大神好,问题是这样的: 最近在看K-means聚类算法的python实现版本,看到了一个朋友写的程序,下面是选取数据集dataSet的k个初始中心的函数 18 def randCent(dataSet, k): 19 n = shape(dataSet)[1] 20 centroids = mat(zeros((k,n))) 21 for j in range(n): 22 minJ = min(dataSet[:,j]) 23 rangeJ = float(max(array(dataSet)[:,j]) - minJ) 24 centroids[:,j] = minJ + rangeJ * random.rand(k,1) 25 return centroids 其中第22行没看明白minJ = min(dataSet[:,j]) dataSet是一个mat类型的numpy矩阵。 dataSet[:,j] 是什么意思啊?请教各位朋友,十分感谢 ``` 其中第22行没看明白minJ = min(dataSet[:,j]) dataSet是一个mat类型的numpy矩阵。 dataSet[:,j] 是什么意思啊?请教各位朋友,十分感谢
python自编逆矩阵遇到的奇怪问题
问题有点长,在这个博文有详细描述: https://blog.csdn.net/qq_42547404/article/details/103346884 就是自编逆矩阵代码结果,直接作为参数传入numpy.dot(),不能得到正确结果,必须要在作为参数传入numpy.dot()前,自己先运行一遍,才能得到正确结果,不知道是什么原因,盼高人指点一二
mxnet自动安装numpy 1.14.6,导致 importError(无法加载multiarray模块)
本人需要安装mxnet,而pip安装时,会自动卸载新版本numpy,重新安装1.14.6版本numpy,安装后numpy报错。于是本人卸载了mxnet和numpy进行测试。单独安装1.14.6版本numpy出错: windows平台,安装正常:pip install -i https://pypi.tuna.tsinghua.edu.cn/simple numpy==1.14.6 import numpy出错:![图片说明](https://img-ask.csdn.net/upload/201905/19/1558227199_638733.png) 新版本numpy正常安装后可以使用,但numpy 1.14.6出错。我的python是3.6版本的。请问这是什么原因?或者如何让mxnet不使用numpy 1.14.6?(经测试,安装1.16.3版本numpy后,mxnet也无法使用)
运用书上的朴素贝叶斯分类代码,但代码出错,怎么解决,大佬求解。。。
``` import numpy as np class Naive_bayes(object): def __init__(self,p0_vector,p1_vector,p_absolute,vocab_set): """ 输入:朴素贝叶斯实例self,p0_vector表示类别c0的单词词频P(X|c0) p1_vector 表示类别c1的单词词频P(X|c1),p_absolute 表示类别c1的概率 P(c1),单词字典vocab_set 输出:无 描述:朴素贝叶斯构造函数 """ self.p0_vector = p0_vector self.p1_vector = p1_vector self.p_absolute = p_absolute self.vocab_set = vocab_set super(Naive_bayes,self).__init__() def create_vocab_list(self,dataset): """ 输入:朴素贝叶斯实例self,训练数据集 dataset 输出: 无 描述:根据测试样本构建你单词字典 """ vocab_set = set([]) for doucument in dataset: vocab_set = vocab_set|set(doucument) self.vocab_set = list(vocab_set) def wordset2vector(self,inputset): """ 输入:朴素贝叶斯实例self,单条文本inputset 输出:文本向量 return_vec 描述:将每条文本转换为数字向量,建立于字典同等大小的文本向量,若语句中的词典在字典表中出现则标记为1,否则为0 """ return_vec = [0]*len(self.vocab_set) for word in inputset: if word in self.vocab_set: return_vec[self.vocab_set.index(word)] += 1 return return_vec def computer_conditon_probablility(self,words_vec,labels): """ 输入:朴素贝叶斯实例self,训练文本向量集合words——vec,文本标签labels 输出:无 描述:根据文本向量集合计算类别c(i)的单词词频P(X|ci)和概率P(ci) """ num_train_docs = len(words_vec) num_words = len(words_vec[0]) p0_num = np.ones(num_words) p1_num = np.ones(num_words) for i in range(num_train_docs): if labels[i] == 1: p1_num += words_vec[i] else: p0_num += words_vec[i] self.p0_vector = np.log(p0_num/sum(p0_num)) self.p1_vector = np.log(p1_num / sum(p1_num)) self.p_absolute = sum(labels)/float(num_train_docs) def fit(self,dataset,labels): """ 输入:朴素贝叶斯实例self,训练文本向量集合dataset,文本标签labels 输出:无 描述:根据训练样本集训练朴素贝叶斯分类器 """ self.create_vocab_list(dataset) # 构建样本单词字典 words_vec = [] for inputset in dataset: words_vec.append(self.wordset2vec(inputset)) # 构建文本向量 self.compute_condition_probability(words_vec,labels) # 计算条件概率P(X|ci)和类别c1的概率P(c1) def predict(self,word_vec): """ 输入:朴素贝叶斯实例self,测试文本向量word__vec 输出:word_vec所属类别 描述:利用朴素贝叶斯分类器预测文本类别 """ p0 = sum(word_vec*self.p0V) + np.log(1.0-self.p_absolute) p1 = sum(word_vec*self.p1V) + np.log(self.p_absolute) return 1 if p1 > p0 else 0 def load_dataset(filename,delimiter=" "): """ 输入:数据文件路径,分隔符 输出:数据集 描述:读取数据文件生成np.nArry类型的数据集 """ dataset = [] labels = [] with open(filename,'r') as fp: # 数据文件内容格式“Daily English Learning” while True: lines = fp.readline().strip() # lines="Daily English Learning" if not lines: break feature = lines.split(delimiter) # feature= ['daily','english','learning','1'] key = int(feature[-1]) values = [v.lower() for v in feature[0:-1]] labels.append(key) dataset.append(values) return dataset,labels if __name__ == "__main__": filename = "bayes.data" dataset,labels = load_dataset(filename) naive_bayes = Naive_bayes() naive_bayes.fit(dataset,labels) testset = ['Learning','English'] test_vec = naive_bayes.wordset2vec(testset) estimate =naive_bayes.predict(test_vec) print('[{0},{1} estimate is:{2}'.format(testset[0],testset[1],estimate)) ``` ![图片说明](https://img-ask.csdn.net/upload/202001/18/1579333779_71473.png)
python中,opencv图片对象如何转化为f.read()这种类型的bytes
我已经知道从numpy.ndarray (图片)到字节流bytes: x = img.tobytes() 但是我现在想要的是将numpy.ndarray (图片)到f.read()这种类型的bytes ``` with open("1.png","rb") as f: bytes=f.read() ``` 如图, numpy.ndarray (图片)使用tobytes()到字节流bytes是上面的编码格式 f.read()是下面的字节编码方式 ![图片说明](https://img-ask.csdn.net/upload/201905/30/1559228339_868408.jpg)
安装了anaconda3,自带numpy库,但不能导入
ImportError Traceback (most recent call last) ~\AppData\Roaming\Python\Python36\site-packages\numpy\core\__init__.py in <module>() 15 try: ---> 16 from . import multiarray 17 except ImportError as exc: ImportError: cannot import name 'multiarray' During handling of the above exception, another exception occurred: ImportError Traceback (most recent call last) <ipython-input-1-5a0bd626bb1d> in <module>() ----> 1 import numpy ~\AppData\Roaming\Python\Python36\site-packages\numpy\__init__.py in <module>() 140 return loader(*packages, **options) 141 --> 142 from . import add_newdocs 143 __all__ = ['add_newdocs', 144 'ModuleDeprecationWarning', ~\AppData\Roaming\Python\Python36\site-packages\numpy\add_newdocs.py in <module>() 11 from __future__ import division, absolute_import, print_function 12 ---> 13 from numpy.lib import add_newdoc 14 15 ############################################################################### ~\AppData\Roaming\Python\Python36\site-packages\numpy\lib\__init__.py in <module>() 6 from numpy.version import version as __version__ 7 ----> 8 from .type_check import * 9 from .index_tricks import * 10 from .function_base import * ~\AppData\Roaming\Python\Python36\site-packages\numpy\lib\type_check.py in <module>() 9 'common_type'] 10 ---> 11 import numpy.core.numeric as _nx 12 from numpy.core.numeric import asarray, asanyarray, array, isnan, zeros 13 from .ufunclike import isneginf, isposinf ~\AppData\Roaming\Python\Python36\site-packages\numpy\core\__init__.py in <module>() 24 Original error was: %s 25 """ % (exc,) ---> 26 raise ImportError(msg) 27 28 for envkey in env_added: ImportError: Importing the multiarray numpy extension module failed. Most likely you are trying to import a failed build of numpy. If you're working with a numpy git repo, try `git clean -xdf` (removes all files not under version control). Otherwise reinstall numpy. Original error was: cannot import name 'multiarray' 问题补充:1.我已经在网上搜索了的问题,有人说需要卸载numpy库后重新装,试了但不管用,同时,我又重装了anaconda,也不管用。 2.我的电脑上还同时安装了独立的python3,python2。python3是默认系统。
在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 ``` 报错如上,为什么会这样报错?如何解决?谢谢!
Java学习的正确打开方式
在博主认为,对于入门级学习java的最佳学习方法莫过于视频+博客+书籍+总结,前三者博主将淋漓尽致地挥毫于这篇博客文章中,至于总结在于个人,实际上越到后面你会发现学习的最好方式就是阅读参考官方文档其次就是国内的书籍,博客次之,这又是一个层次了,这里暂时不提后面再谈。博主将为各位入门java保驾护航,各位只管冲鸭!!!上天是公平的,只要不辜负时间,时间自然不会辜负你。 何谓学习?博主所理解的学习,它是一个过程,是一个不断累积、不断沉淀、不断总结、善于传达自己的个人见解以及乐于分享的过程。
程序员必须掌握的核心算法有哪些?
由于我之前一直强调数据结构以及算法学习的重要性,所以就有一些读者经常问我,数据结构与算法应该要学习到哪个程度呢?,说实话,这个问题我不知道要怎么回答你,主要取决于你想学习到哪些程度,不过针对这个问题,我稍微总结一下我学过的算法知识点,以及我觉得值得学习的算法。这些算法与数据结构的学习大多数是零散的,并没有一本把他们全部覆盖的书籍。下面是我觉得值得学习的一些算法以及数据结构,当然,我也会整理一些看过...
大学四年自学走来,这些私藏的实用工具/学习网站我贡献出来了
大学四年,看课本是不可能一直看课本的了,对于学习,特别是自学,善于搜索网上的一些资源来辅助,还是非常有必要的,下面我就把这几年私藏的各种资源,网站贡献出来给你们。主要有:电子书搜索、实用工具、在线视频学习网站、非视频学习网站、软件下载、面试/求职必备网站。 注意:文中提到的所有资源,文末我都给你整理好了,你们只管拿去,如果觉得不错,转发、分享就是最大的支持了。 一、电子书搜索 对于大部分程序员...
linux系列之常用运维命令整理笔录
本博客记录工作中需要的linux运维命令,大学时候开始接触linux,会一些基本操作,可是都没有整理起来,加上是做开发,不做运维,有些命令忘记了,所以现在整理成博客,当然vi,文件操作等就不介绍了,慢慢积累一些其它拓展的命令,博客不定时更新 free -m 其中:m表示兆,也可以用g,注意都要小写 Men:表示物理内存统计 total:表示物理内存总数(total=used+free) use...
比特币原理详解
一、什么是比特币 比特币是一种电子货币,是一种基于密码学的货币,在2008年11月1日由中本聪发表比特币白皮书,文中提出了一种去中心化的电子记账系统,我们平时的电子现金是银行来记账,因为银行的背后是国家信用。去中心化电子记账系统是参与者共同记账。比特币可以防止主权危机、信用风险。其好处不多做赘述,这一层面介绍的文章很多,本文主要从更深层的技术原理角度进行介绍。 二、问题引入 假设现有4个人...
程序员接私活怎样防止做完了不给钱?
首先跟大家说明一点,我们做 IT 类的外包开发,是非标品开发,所以很有可能在开发过程中会有这样那样的需求修改,而这种需求修改很容易造成扯皮,进而影响到费用支付,甚至出现做完了项目收不到钱的情况。 那么,怎么保证自己的薪酬安全呢? 我们在开工前,一定要做好一些证据方面的准备(也就是“讨薪”的理论依据),这其中最重要的就是需求文档和验收标准。一定要让需求方提供这两个文档资料作为开发的基础。之后开发...
网页实现一个简单的音乐播放器(大佬别看。(⊙﹏⊙))
今天闲着无事,就想写点东西。然后听了下歌,就打算写个播放器。 于是乎用h5 audio的加上js简单的播放器完工了。 演示地点演示 html代码如下` music 这个年纪 七月的风 音乐 ` 然后就是css`*{ margin: 0; padding: 0; text-decoration: none; list-...
Python十大装B语法
Python 是一种代表简单思想的语言,其语法相对简单,很容易上手。不过,如果就此小视 Python 语法的精妙和深邃,那就大错特错了。本文精心筛选了最能展现 Python 语法之精妙的十个知识点,并附上详细的实例代码。如能在实战中融会贯通、灵活使用,必将使代码更为精炼、高效,同时也会极大提升代码B格,使之看上去更老练,读起来更优雅。
数据库优化 - SQL优化
以实际SQL入手,带你一步一步走上SQL优化之路!
通俗易懂地给女朋友讲:线程池的内部原理
餐盘在灯光的照耀下格外晶莹洁白,女朋友拿起红酒杯轻轻地抿了一小口,对我说:“经常听你说线程池,到底线程池到底是个什么原理?”
经典算法(5)杨辉三角
杨辉三角 是经典算法,这篇博客对它的算法思想进行了讲解,并有完整的代码实现。
使用 Docker 部署 Spring Boot 项目
Docker 技术发展为微服务落地提供了更加便利的环境,使用 Docker 部署 Spring Boot 其实非常简单,这篇文章我们就来简单学习下。首先构建一个简单的 S...
英特尔不为人知的 B 面
从 PC 时代至今,众人只知在 CPU、GPU、XPU、制程、工艺等战场中,英特尔在与同行硬件芯片制造商们的竞争中杀出重围,且在不断的成长进化中,成为全球知名的半导体公司。殊不知,在「刚硬」的背后,英特尔「柔性」的软件早已经做到了全方位的支持与支撑,并持续发挥独特的生态价值,推动产业合作共赢。 而对于这一不知人知的 B 面,很多人将其称之为英特尔隐形的翅膀,虽低调,但是影响力却不容小觑。 那么,在...
面试官:你连RESTful都不知道我怎么敢要你?
干货,2019 RESTful最贱实践
刷了几千道算法题,这些我私藏的刷题网站都在这里了!
遥想当年,机缘巧合入了 ACM 的坑,周边巨擘林立,从此过上了"天天被虐似死狗"的生活… 然而我是谁,我可是死狗中的战斗鸡,智力不够那刷题来凑,开始了夜以继日哼哧哼哧刷题的日子,从此"读题与提交齐飞, AC 与 WA 一色 ",我惊喜的发现被题虐既刺激又有快感,那一刻我泪流满面。这么好的事儿作为一个正直的人绝不能自己独享,经过激烈的颅内斗争,我决定把我私藏的十几个 T 的,阿不,十几个刷题网...
白话阿里巴巴Java开发手册高级篇
不久前,阿里巴巴发布了《阿里巴巴Java开发手册》,总结了阿里巴巴内部实际项目开发过程中开发人员应该遵守的研发流程规范,这些流程规范在一定程度上能够保证最终的项目交付质量,通过在时间中总结模式,并推广给广大开发人员,来避免研发人员在实践中容易犯的错误,确保最终在大规模协作的项目中达成既定目标。 无独有偶,笔者去年在公司里负责升级和制定研发流程、设计模板、设计标准、代码标准等规范,并在实际工作中进行...
SQL-小白最佳入门sql查询一
不要偷偷的查询我的个人资料,即使你再喜欢我,也不要这样,真的不好;
redis分布式锁,面试官请随便问,我都会
文章有点长并且绕,先来个图片缓冲下! 前言 现在的业务场景越来越复杂,使用的架构也就越来越复杂,分布式、高并发已经是业务要求的常态。像腾讯系的不少服务,还有CDN优化、异地多备份等处理。 说到分布式,就必然涉及到分布式锁的概念,如何保证不同机器不同线程的分布式锁同步呢? 实现要点 互斥性,同一时刻,智能有一个客户端持有锁。 防止死锁发生,如果持有锁的客户端崩溃没有主动释放锁,也要保证锁可以正常释...
项目中的if else太多了,该怎么重构?
介绍 最近跟着公司的大佬开发了一款IM系统,类似QQ和微信哈,就是聊天软件。我们有一部分业务逻辑是这样的 if (msgType = "文本") { // dosomething } else if(msgType = "图片") { // doshomething } else if(msgType = "视频") { // doshomething } else { // doshom...
Nginx 原理和架构
Nginx 是一个免费的,开源的,高性能的 HTTP 服务器和反向代理,以及 IMAP / POP3 代理服务器。Nginx 以其高性能,稳定性,丰富的功能,简单的配置和低资源消耗而闻名。 Nginx 的整体架构 Nginx 里有一个 master 进程和多个 worker 进程。master 进程并不处理网络请求,主要负责调度工作进程:加载配置、启动工作进程及非停升级。worker 进程负责处...
“狗屁不通文章生成器”登顶GitHub热榜,分分钟写出万字形式主义大作
一、垃圾文字生成器介绍 最近在浏览GitHub的时候,发现了这样一个骨骼清奇的雷人项目,而且热度还特别高。 项目中文名:狗屁不通文章生成器 项目英文名:BullshitGenerator 根据作者的介绍,他是偶尔需要一些中文文字用于GUI开发时测试文本渲染,因此开发了这个废话生成器。但由于生成的废话实在是太过富于哲理,所以最近已经被小伙伴们给玩坏了。 他的文风可能是这样的: 你发现,...
程序员:我终于知道post和get的区别
是一个老生常谈的话题,然而随着不断的学习,对于以前的认识有很多误区,所以还是需要不断地总结的,学而时习之,不亦说乎
《程序人生》系列-这个程序员只用了20行代码就拿了冠军
你知道的越多,你不知道的越多 点赞再看,养成习惯GitHub上已经开源https://github.com/JavaFamily,有一线大厂面试点脑图,欢迎Star和完善 前言 这一期不算《吊打面试官》系列的,所有没前言我直接开始。 絮叨 本来应该是没有这期的,看过我上期的小伙伴应该是知道的嘛,双十一比较忙嘛,要值班又要去帮忙拍摄年会的视频素材,还得搞个程序员一天的Vlog,还要写BU...
加快推动区块链技术和产业创新发展,2019可信区块链峰会在京召开
11月8日,由中国信息通信研究院、中国通信标准化协会、中国互联网协会、可信区块链推进计划联合主办,科技行者协办的2019可信区块链峰会将在北京悠唐皇冠假日酒店开幕。   区块链技术被认为是继蒸汽机、电力、互联网之后,下一代颠覆性的核心技术。如果说蒸汽机释放了人类的生产力,电力解决了人类基本的生活需求,互联网彻底改变了信息传递的方式,区块链作为构造信任的技术有重要的价值。   1...
Java世界最常用的工具类库
Apache Commons Apache Commons有很多子项目 Google Guava 参考博客
程序员把地府后台管理系统做出来了,还有3.0版本!12月7号最新消息:已在开发中有github地址
第一幕:缘起 听说阎王爷要做个生死簿后台管理系统,我们派去了一个程序员…… 996程序员做的梦: 第一场:团队招募 为了应对地府管理危机,阎王打算找“人”开发一套地府后台管理系统,于是就在地府总经办群中发了项目需求。 话说还是中国电信的信号好,地府都是满格,哈哈!!! 经常会有外行朋友问:看某网站做的不错,功能也简单,你帮忙做一下? 而这次,面对这样的需求,这个程序员...
网易云6亿用户音乐推荐算法
网易云音乐是音乐爱好者的集聚地,云音乐推荐系统致力于通过 AI 算法的落地,实现用户千人千面的个性化推荐,为用户带来不一样的听歌体验。 本次分享重点介绍 AI 算法在音乐推荐中的应用实践,以及在算法落地过程中遇到的挑战和解决方案。 将从如下两个部分展开: AI算法在音乐推荐中的应用 音乐场景下的 AI 思考 从 2013 年 4 月正式上线至今,网易云音乐平台持续提供着:乐屏社区、UGC...
【技巧总结】位运算装逼指南
位算法的效率有多快我就不说,不信你可以去用 10 亿个数据模拟一下,今天给大家讲一讲位运算的一些经典例子。不过,最重要的不是看懂了这些例子就好,而是要在以后多去运用位运算这些技巧,当然,采用位运算,也是可以装逼的,不信,你往下看。我会从最简单的讲起,一道比一道难度递增,不过居然是讲技巧,那么也不会太难,相信你分分钟看懂。 判断奇偶数 判断一个数是基于还是偶数,相信很多人都做过,一般的做法的代码如下...
为什么要学数据结构?
一、前言 在可视化化程序设计的今天,借助于集成开发环境可以很快地生成程序,程序设计不再是计算机专业人员的专利。很多人认为,只要掌握几种开发工具就可以成为编程高手,其实,这是一种误解。要想成为一个专业的开发人员,至少需要以下三个条件: 1) 能够熟练地选择和设计各种数据结构和算法 2) 至少要能够熟练地掌握一门程序设计语言 3) 熟知所涉及的相关应用领域的知识 其中,后两个条件比较容易实现,而第一个...
Android 9.0 init 启动流程
阅读五分钟,每日十点,和您一起终身学习,这里是程序员Android本篇文章主要介绍Android开发中的部分知识点,通过阅读本篇文章,您将收获以下内容:一、启动流程概述一、 启动流程概述Android启动流程跟Linux启动类似,大致分为如下五个阶段。1.开机上电,加载固化的ROM。2.加载BootLoader,拉起Android OS。3.加载Uboot,初始外设,引导Kernel启动等。...
相关热词 c#委托 逆变与协变 c#新建一个项目 c#获取dll文件路径 c#子窗体调用主窗体事件 c# 拷贝目录 c# 调用cef 网页填表c#源代码 c#部署端口监听项目、 c#接口中的属性使用方法 c# 昨天
立即提问