AttributeError: 'module' object has no attribute 'to_rgba' 20C

I met a strange problem when i using matplotlib with python 2.7, ubuntu 16.04 and jupyter web.

The code is very simple, like:

%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt

x = np.linspace(0, 10, 100)
y = np.sin(x)
plt.plot(x,y)
plt.show()

[]

AttributeError Traceback (most recent call last)
/home/******/.local/lib/python2.7/site-packages/ipykernel/pylab/backend_inline.pyc in show(close, block)
37 display(
38 figure_manager.canvas.figure,
---> 39 metadata=_fetch_figure_metadata(figure_manager.canvas.figure)
40 )
41 finally:

/home/******/.local/lib/python2.7/site-packages/ipykernel/pylab/backend_inline.pyc in _fetch_figure_metadata(fig)
172 """Get some metadata to help with displaying a figure."""
173 # determine if a background is needed for legibility
--> 174 if _is_transparent(fig.get_facecolor()):
175 # the background is transparent
176 ticksLight = _is_light([label.get_color()

/home/******/.local/lib/python2.7/site-packages/ipykernel/pylab/backend_inline.pyc in _is_transparent(color)
193 def _is_transparent(color):
194 """Determine transparency from alpha."""
--> 195 rgba = colors.to_rgba(color)
196 return rgba[3] < .5

AttributeError: 'module' object has no attribute 'to_rgba'

国外的一个朋友问我的,我也不知道为什么,matplotlib在终端用的好好地,在jupyter notebook中就报错了.......
很奇怪的一个错误, 哪位大佬帮解决一下。 错误指向colors没有to_rgba属性。
谢谢大佬

2个回答

U can try this, It may works.

 sudo pip install matplotlib==2.2.0
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
NS3进行可视化编译时出错AttributeError: 'module' object has no attribute 'require_foreign'
在安装NS3后想通过可视化界面看示例编译出错 ``` @ubuntu:~/software/ns-allinone-3.29/ns-3.29$ ./waf --pyrun src/flow-monitor/examples/wifi-olsr-flowmon.py --vis Waf: Entering directory `/home/Alao8B/software/ns-allinone-3.29/ns-3.29/build' [2497/2757] Linking build/examples/tutorial/ns3.29-third-debug Waf: Leaving directory `/home/Alao8B/software/ns-allinone-3.29/ns-3.29/build' Build commands will be stored in build/compile_commands.json 'build' finished successfully (5.867s) Traceback (most recent call last): File "<string>", line 1, in <module> File "/home/XXX/software/ns-allinone-3.29/ns-3.29/src/visualizer/visualizer/__init__.py", line 2, in <module> from core import start, register_plugin, set_bounds, add_initialization_hook File "/home/XXX/software/ns-allinone-3.29/ns-3.29/src/visualizer/visualizer/core.py", line 41, in <module> gi.require_foreign("cairo") AttributeError: 'module' object has no attribute 'require_foreign' ``` 请问大家有没有遇到类似问题 谢谢
AttributeError: 'NoneType' object has no attribute 'append'
拟输出一个日期列表: ``` file=open("C:/Users/jyz_1/Desktop/新建文本文档.txt") file=file.read() lsy=[] dates=file.split("\n") for date in dates: while "-" in date: p1=date.index('-')#the first - p2=date.find('-',p1+1)#the second - month=date[p1+1:p2] day=date[p2+1:-1] date_on_x=int(month+day) lsy=lsy.append(date_on_x) ``` 报错: ``` Traceback (most recent call last): File "C:\Users\jyz_1\AppData\Local\Programs\Python\Python37-32\32rx.py", line 26, in <module> lsy=lsy.append(t) AttributeError: 'NoneType' object has no attribute 'append' ``` 难道lsy不是列表? 在shell中输入: ``` >>> lsy=[] >>> a='2015-1-1' >>> lsy.append(a) >>> lsy ['2015-1-1'] ``` 结果正常。 百思不得其解,求大神解惑。
Python 创建Dog类时 报错AttributeError: 'Dog' object has no attribute 'sit'
![图片说明](https://img-ask.csdn.net/upload/201911/17/1573972296_14099.png) 新手学习,求教大佬们是啥错误,应该怎么改代码lei >>> class Dog(): def __init__(self,name,age): self.name = name self.age = age >>> def sit(self): print(self.name.title() + "is now sitting.") >>> def roll_over(self): print(self.name.title() + "is now sitting.") >>> my_dog = Dog('willie',6) >>> print("My dog's name is" + my_dog.name.title()+".") My dog's name isWillie. >>> print("My dog is" + str(my_dog.age)+"years old.") My dog is6years old. >>> my_dog.sit() Traceback (most recent call last): File "<pyshell#14>", line 1, in <module> my_dog.sit() AttributeError: 'Dog' object has no attribute 'sit'
出现AttributeError: 'NoneType' object has no attribute 'text'错误,无法解决....能答否?
今天在做爬虫练习时遇到: Traceback (most recent call last): File "C:\Users\Liangdawang\Desktop\crawler.py", line 7, in <module> print(title.text) AttributeError: 'NoneType' object has no attribute 'text' 本人小白 ,不知道为什么会出现这种错误,希望大佬解答仔细一点,还有就是对这种类型的解释以及类似的错误还有哪些 原代码: ``` from requests_html import HTMLSession session = HTMLSession() r = session.get('https://movie.douban.com/subject/1292052') title = r.html.find('#app > div > div > div.container > div:nth-child(6) > h3:nth-child(26) > b',first=True) print(title.text) ``` 错误截图: ![图片说明](https://img-ask.csdn.net/upload/201909/27/1569590119_512714.jpg)
生成二维均匀分布的三维图报错AttributeError: 'int' object has no attribute 'ndim'?
* 生成二维均匀分布的三维图报错 * 代码如下: ``` from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt import numpy as np fig = plt.figure() ax = fig.gca(projection='3d') x=np.arange(0,1,0.01) y=np.arange(0,1,0.01) X,Y=np.meshgrid(x,y) Z1=1 Z2=0 surf=ax.plot_surface(X,Y,Z1,color='b') surf=ax.plot_surface(X,Y,Z2,color='r') plt.show() ``` * 报错信息 Traceback (most recent call last): File "二维均匀分布.py", line 15, in <module> surf=ax.plot_surface(X,Y,Z1,color='b') File "E:\DataAnalysis\python-3.7.0\lib\site-packages\mpl_toolkits\mplot3d\axes3d.py", line 1610, in plot_surface if Z.ndim != 2: AttributeError: 'int' object has no attribute 'ndim' * 截图 ![图片说明](https://img-ask.csdn.net/upload/201904/15/1555301940_905474.jpg) 给底面Z=0和均匀分布的平面Z=1染色,但显示这个问题,搜索了下,基本上没有与这个相似的。。。请教该如何改啊!~
怎么解决报错信息,AttributeError: 'RangeIndex' object has no attribute 'to_pydatetime'?
想要用python画股票K线图,但是代码运营的时候却报错,难道不能用index.to_pydatatime吗? 求大神解决! 代码如下: ``` import mpl_finance as mpf from pandas.plotting import register_matplotlib_converters register_matplotlib_converters() fig, (ax1, ax2) = plt.subplots(2,1, sharex=True) mpf.candlestick_ohlc(ax1, zip(dates.date2num(stock_data.index.to_pydatetime()), stock_data['open'], stock_data['high'], stock_data['low'], stock_data['close']), width=0.8, colorup='g', colordown='r') ``` 报错如下: ``` An exception has occurred, use %tb to see the full traceback. SystemExit: usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...] or: setup.py --help [cmd1 cmd2 ...] or: setup.py --help-commands or: setup.py cmd --help error: no commands supplied --------------------------------------------------------------------------- AttributeError Traceback (most recent call last) <ipython-input-15-e50d6a9afbf4> in <module> 5 register_matplotlib_converters() 6 ----> 7 mpf.candlestick_ohlc(ax1, zip(dates.date2num(stock_data.index.to_pydatetime()), 8 stock_data['open'], stock_data['high'], 9 stock_data['low'], stock_data['close']), AttributeError: 'RangeIndex' object has no attribute 'to_pydatetime' ```
运行mixmatch源码CIFAR10数据集时报错AttributeError: 'CIFAR10' object has no attribute 'targets',是怎么回事?
1. 在运行mixmatch程序的时候,用torchvision.datasets载入CIFAT10的时候出现AttributeError: 'CIFAR10' object has no attribute 'targets',错误 还有一个问题就是:由于用torchvision下载太慢,我先把数据集下下来了,然后放在了data目录下面,这个对结果会有影响嘛? 希望大家可以给点建议和意见,谢谢。 加载数据集的代码如下: ``` def get_cifar10(root, n_labeled, transform_train=None, transform_val=None, download=True): base_dataset = torchvision.datasets.CIFAR10(root, train=True, target_transform=True, download=download,) train_labeled_idxs, train_unlabeled_idxs, val_idxs = train_val_split(base_dataset.targets, int(n_labeled/10)) train_labeled_dataset = CIFAR10_labeled(root, train_labeled_idxs, train=True, transform=transform_train) train_unlabeled_dataset = CIFAR10_unlabeled(root, train_unlabeled_idxs, train=True, transform=TransformTwice(transform_train)) val_dataset = CIFAR10_labeled(root, val_idxs, train=True, transform=transform_val, download=True) test_dataset = CIFAR10_labeled(root, train=False, transform=transform_val, download=True) print (f"#Labeled: {len(train_labeled_idxs)} #Unlabeled: {len(train_unlabeled_idxs)} #Val: {len(val_idxs)}") return train_labeled_dataset, train_unlabeled_dataset, val_dataset, test_dataset ``` ``` def train_val_split(labels, n_labeled_per_class): labels = np.array(labels) train_labeled_idxs = [] train_unlabeled_idxs = [] val_idxs = [] for i in range(10): idxs = np.where(labels == i)[0] np.random.shuffle(idxs) train_labeled_idxs.extend(idxs[:n_labeled_per_class]) train_unlabeled_idxs.extend(idxs[n_labeled_per_class:-500]) val_idxs.extend(idxs[-500:]) np.random.shuffle(train_labeled_idxs) np.random.shuffle(train_unlabeled_idxs) np.random.shuffle(val_idxs) return train_labeled_idxs, train_unlabeled_idxs, val_idxs ``` 错误信息如下 (base) D:\CSStudy\PycharmProject\MixMatch-pytorch-master>python train.py --gpu 0 --n-labeled 250 --out cifar10@250 ==> Preparing cifar10 Using downloaded and verified file: ./data\cifar-10-python.tar.gz Traceback (most recent call last): File "train.py", line 431, in <module> main() File "train.py", line 88, in main train_labeled_set, train_unlabeled_set, val_set, test_set = dataset.get_cifar10('./data', args.n_labeled, transform_train=transform_train, transf orm_val=transform_val) File "D:\CSStudy\PycharmProject\MixMatch-pytorch-master\dataset\cifar10.py", line 21, in get_cifar10 train_labeled_idxs, train_unlabeled_idxs, val_idxs = train_val_split(base_dataset.targets, int(n_labeled/10)) AttributeError: 'CIFAR10' object has no attribute 'targets'
AttributeError: '----' object has no attribute 'driver'。
这几天公司做web自动化脚本,,等做完我用着好好的,别人一用突然有的能跑有的报这个错误, selenium.common.exceptions.WebDriverException: Message: 'chromedriver.exe' executable needs to be in PATH. Please see AttributeError: 'BasicInformationCase' object has no attribute 'driver' 在网上找了很多类似的方法可是有的说setUp问题,关键我这个没有写setUp方法啊! 而且我的电脑就能都跑通,别人的电脑就有的能跑通,有的不能跑通,求助各位大神帮帮忙,看看什么原因 异常信息: 'Traceback (most recent call last): File "D:\software\python3.7.2\lib\site-packages\selenium\webdriver\common\service.py", line 76, in start stdin=PIPE) File "D:\software\python3.7.2\lib\subprocess.py", line 775, in __init__ restore_signals, start_new_session) File "D:\software\python3.7.2\lib\subprocess.py", line 1178, in _execute_child startupinfo) FileNotFoundError: [WinError 2] 系统找不到指定的文件。 During handling of the above exception, another exception occurred: Traceback (most recent call last): File "D:\工作文件\自动化脚本\abc\Template\BasicInformationCase.py", line 35, in BasicInformationCase text = self.__Demo(excelData,Number_of_cases, i, flow) File "D:\工作文件\自动化脚本\abc\Template\BasicInformationCase.py", line 70, in __Demo self.__Init_driver_Chrome() File "D:\工作文件\自动化脚本\abc\Template\BasicInformationCase.py", line 144, in __Init_driver_Chrome self.driver = webdriver.Chrome(executable_path='C:\\Program Files (x86)\\Google\\Chrome\\Application\\chromedriver.exe', chrome_options=options) # 启动浏览器 File "D:\software\python3.7.2\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 73, in __init__ self.service.start() File "D:\software\python3.7.2\lib\site-packages\selenium\webdriver\common\service.py", line 83, in start os.path.basename(self.path), self.start_error_message) selenium.common.exceptions.WebDriverException: Message: 'chromedriver.exe' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home 异常信息: 'Traceback (most recent call last): File "D:\software\python3.7.2\lib\site-packages\selenium\webdriver\common\service.py", line 76, in start stdin=PIPE) File "D:\software\python3.7.2\lib\subprocess.py", line 775, in __init__ restore_signals, start_new_session) File "D:\software\python3.7.2\lib\subprocess.py", line 1178, in _execute_child startupinfo) FileNotFoundError: [WinError 2] 系统找不到指定的文件。 During handling of the above exception, another exception occurred: Traceback (most recent call last): File "D:\工作文件\自动化脚本\abc\Template\BasicInformationCase.py", line 35, in BasicInformationCase text = self.__Demo(excelData,Number_of_cases, i, flow) File "D:\工作文件\自动化脚本\abc\Template\BasicInformationCase.py", line 70, in __Demo self.__Init_driver_Chrome() File "D:\工作文件\自动化脚本\abc\Template\BasicInformationCase.py", line 144, in __Init_driver_Chrome self.driver = webdriver.Chrome(executable_path='C:\\Program Files (x86)\\Google\\Chrome\\Application\\chromedriver.exe', chrome_options=options) # 启动浏览器 File "D:\software\python3.7.2\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 73, in __init__ self.service.start() File "D:\software\python3.7.2\lib\site-packages\selenium\webdriver\common\service.py", line 83, in start os.path.basename(self.path), self.start_error_message) selenium.common.exceptions.WebDriverException: Message: 'chromedriver.exe' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home 异常信息: 'Traceback (most recent call last): File "D:\工作文件\自动化脚本\abc\Template\BasicInformationCase.py", line 35, in BasicInformationCase text = self.__Demo(excelData,Number_of_cases, i, flow) File "D:\工作文件\自动化脚本\abc\Template\BasicInformationCase.py", line 77, in __Demo restext.append(bsm.BasicInformation_Son_Module(self.driver,excelData,Number_of_cases, i)) AttributeError: 'BasicInformationCase' object has no attribute 'driver'
笨方法学python3上的习题43AttributeError: 'NoneType' object has no attribute 'enter',哪错了
from sys import exit from random import randint from textwrap import dedent class Scene(object): def enter(self): print("This scene is not yet configured.") print("Subclass it and implement enter().") exit(1) class Engine(object): def __init__(self,scene_map): self.scene_map = scene_map def play(self): current_scene = self.scene_map.opening_scene() last_scene = self.scene_map.next_scene('finished') while current_scene != last_scene: next_scene_name = current_scene.enter() current_scene = self.scene_map.next_scene(next_scene_name) # be sure to print out the last scene current_scene.enter() class Death(Scene): quips = [ "You died. You kinda suck at this.", "Your mom would be pround...if she were smarter.", "such a luser.", "I have a small puppy that's better st this.", "You're worse than your Dad's jokes.", ] def enter(self): print(Death.quips[randint(0, len(self.quips)-1)]) exit(1) class CentralCorridor(Scene): def enter(self): print(dedent(""" The Gothons of Planet Percal #25 have invaded your ship and destroyed your entire crew. You are the last surviving member and your last mission is to get the neutron destruct bomb from the Weapons Armory, put it in the bridge, and blow the ship up after getting into an escape pod. You're runing down the central corridor to the Weapons Armory when a Gothon jumps out, red scaly skin, dark grimy teeth, and evil clown costume flowing around his hate filled body. He's blocking the door to the Armory and zbout to pull a weapon to blast you. """)) action = input("> ") if action == "shoot!": print(dedent(""" Quick on the draw you yank out your blaster and fire it at the Gothon. His clown costume is flowing and moving around his body, which throws off your aim. Your laser hits his costume but misses him entirely. This completely ruins his brand new costume his mother bought him, which makes him fly into an insane rage and blast you repeattedly in the face until you are dead. Then he eats you. """)) return 'death' elif action == "dodge!": print(dedent(""" Lke a world class boxer you dodge, weave, slip and slide right as the Gothon's blaster cranks a laser past your head. In the middle of your artful dodge your foot slips and you bang your head on the metal wall and pass out. You wake up shortly after only to die as the Gothon stomps on your head and eats you. """)) return 'death' elif action == "tell a joke": print(dedent(""" Lucky for you they made you learn Gothon insults in the academy. You tell the one Gothon joke you know: Lbhe zbgure vf fb sng, jura fur fvgf nebhaq gur ubhfr, fur fvgf nebhaq gur ubhfr. The Gothon stops, tries not to laugh, then busts out laughing and can't move. While he's laughing you run up and shoot him square in the head putting him down, then through the Weapon Armory door. """)) return 'laser_weapon_armory' else: print("DOES NOT COMPUTE!") return 'central_corridor' class LaserWeaponArmory(Scene): def enter(self): print(dedent(""" Youd do a dive roll into the Weapon Armory, crouch and scan the room for more Gothons that might be hiding. It's dead quiet, too quiet,You stand up and run to the far side off the room and find the neutron bomb in its container. There's a keypad lock on box and you need the code to get the bomb out. If you get the code wrong 10 times then the lock closes forever and you can't get the bomb. The code is 3 digits. """)) code = f"{randint(1,9)}{randint(1,9)}{randint(1,9)}" guess = input("[keypad]> ") guesses = 0 while guess != code and guesses<10: print("BZZZZEDDD!") guesses += 1 guess = input("[keypad]> ") if guess == code: print(dedent(""" The container clicks open and the seal breaks, letting gas out. You grab the neutron bomb and run as fast as you can to the bridge where you must place it in the right spot. """)) return 'the bridge' else: print(dedent(""" The lock buzzes one last time and then you hear a sickening melting sound as the mechanism is fused together. You decide to sit there, and finally the Gothons blow up the ship from their ship and you die. """)) return 'death' class TheBridge(Scene): def enter(self): print(dedent(""" You burst onto the Bridge eith the entron destruct bomb under your arm and surprise 5 Gonthons who are trying to take control of the ship. Each of them has an even uglier clown sostume than last.They have't pulled their weapons out yet, as they see the active bomb under your arm and don't want to set it off. """)) action = input("> ") if action == "throw the bomb": print(dedent(""" In a panic you throw the bomb at group of Gothons and make a leap for the door. Right as you drop it a Gothon shoots you right in the back killing you. As you die you see another Gothon frantically try to disarm the bomb. You die knowing they will probably blow up when it goes off. """)) return 'death' elif action == "slowly place the bomb": print(dedent("""" You point your blaster at the bomb under your arm and the Gothons put their hands up adn start to sweat. You inch backward to the door, open it, and then carefully place the bomb on the floor, pointing your blaster at it. You then jump back through the door punch the close button and blast the lock so the Gothons can't get out. Now that bomb is placed you run to the escape pod to get off this tin can. """)) return 'escape_pod' else: print("DOES NOT COMPUTE!") return 'the_bridge' class EscapePod(Scene): def EscapePod(self): print(dedent(""" You rush through the ship desperately trying to make it to the escape pod before the whole ship explodes. It seems like hardly any Gothons are on the ship, so you run is clear of interference. You get to the chamber with the escape pods, and now need to pick one to take. Some of them could be damaged but you don't have time to look. There;s 5pods, which one do you take? """)) good_pod = randint(1,5) guess = input("[pod #> ") if int(guess) != good_pod: print(dedent(""" You jump into pod {guess} and hit the eject button. The pod escapes out into the void of space, then implodes as the hull ruptures, crushing your body into jam jelly. """)) return 'death' else: print(dedent(""" You jump into pod {guess} and hit the eject button. The pod easily slides out into space heading to the plantes below. As it flies to the planet, you look back and see your ship implode then explode like a bright star, taking out the Gothon ship at the same time. You won! """)) return 'finished' class Finished(Scene): def enter(self): print("You won! Good job.") return 'finished' class Map(object): scenes = { 'central_corridor': CentralCorridor(), 'laser_weapon_armory':LaserWeaponArmory(), 'the_bridge':TheBridge(), 'escape_pod':EscapePod(), 'death':Death(), 'finished':Finished(), } def __init__(self, start_scene): self.start_scene = start_scene def next_scene(self, scene_name): val = Map.scenes.get(scene_name) return val def opening_scene(self,): return self.next_scene(self.start_scene) a_map = Map('central_corrider') a_game = Engine(a_map) a_game.play() 返回结果: Traceback (most recent call last): File "F:/Python/test43.py", line 228, in <module> a_game.play() File "F:/Python/test43.py", line 18, in play next_scene_name = current_scene.enter() AttributeError: 'NoneType' object has no attribute 'enter' Process finished with exit code 1 看了好久,就是找不到是哪里错了,很烦
python报错 wxpython运行出错
AttributeError: 'module' object has no attribute 'frame'
jupyter notebook 进行impor keras时出现更重问题,解决一个出现一个,有谁知道怎么回事么?
import keras时 总是出现: cannot import name 'xx' from 'xxx' AttributeError: module 'tensorflow' has no attribute 'xxxx' xxxxxx 'module' object has no attribute 'xxxxx' 尝试重装,更新都不行。。
python3.1里urllib的问题 求帮忙解答!!谢谢!!
在使用urlib时,data = urllib.urlencode(values) 该语句处报错,提示AttributeError: 'module' object has no attribute 'urlencode' 在网上查说是python3之后需要data = urllib.parse.urlencode(values) 这样调用,但是这样调用后就报错AttributeError: 'module' object has no attribute 'parse' 请问有人知道这是什么情况嘛 拜托解答一下吧
Python错误 让我难眠
AttributeError: 'module' object has no attribute 'cv_dist_l2'
Python报错了 我哭了
AttributeError: 'module' object has no attribute 'cv_dist_l2'
简单的while 循环问题 遇到报错:'str' object has no attribute 'pop'
hi 各位高手: 愿请各位不吝赐教: 想要实现一个类似于“弹夹”的功能:原集合是number = ('a','b','c','d','e','f'),想要写一个循环语句使得每次 有且仅有一个number中的元素被pop掉,并流到集合now=[]中,而后这些数字被累计到集合done =[]中, 请问这个功能要怎么循环起来。 尝试着写了一个程序,如下: number = ('a','b','c','d','e','f') numerL =list(number) now =[] nowL=list(now) done=[] doneL=list(done) while len(numerL) > 0: numerL = numerL.pop() nowL = numerL.pop(0) doneL = now.append(numerL) print("number列:",numerL) print("now列:",nowL) print("done列",doneL) 但得到报错: Traceback (most recent call last): File "C:/Users/lenovo/PycharmProjects/Test.9.16/tests/have a try.py", line 17, in <module> nowL = numerL.pop() AttributeError: 'str' object has no attribute 'pop' 请问该怎样解决
请问各位大神 python怎么装tsne包
用的是anaconda2和python2.7版本 用python setup.py install的方法 报错AttributeError:“module”object has no attribute “SafeConfigParser”怎么解决
请各位大神看看这个简单的python错误 谢谢
![图片说明](https://img-ask.csdn.net/upload/201603/23/1458700353_605111.png) AttributeError: 'module' object has no attribute 'utf' 求助
python让我苦了好久 求解求解
源码:dist_transform=cv2.distanceTransform(opening.cv2.DIST_L2,5) 为什么会报下面的错误 AttributeError: 'module' object has no attribute 'cv_dist_l2'
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' ``` 一直解决不了
爬虫福利二 之 妹子图网MM批量下载
爬虫福利一:27报网MM批量下载    点击 看了本文,相信大家对爬虫一定会产生强烈的兴趣,激励自己去学习爬虫,在这里提前祝:大家学有所成! 目标网站:妹子图网 环境:Python3.x 相关第三方模块:requests、beautifulsoup4 Re:各位在测试时只需要将代码里的变量 path 指定为你当前系统要保存的路径,使用 python xxx.py 或IDE运行即可。
Java学习的正确打开方式
在博主认为,对于入门级学习java的最佳学习方法莫过于视频+博客+书籍+总结,前三者博主将淋漓尽致地挥毫于这篇博客文章中,至于总结在于个人,实际上越到后面你会发现学习的最好方式就是阅读参考官方文档其次就是国内的书籍,博客次之,这又是一个层次了,这里暂时不提后面再谈。博主将为各位入门java保驾护航,各位只管冲鸭!!!上天是公平的,只要不辜负时间,时间自然不会辜负你。 何谓学习?博主所理解的学习,它
程序员必须掌握的核心算法有哪些?
由于我之前一直强调数据结构以及算法学习的重要性,所以就有一些读者经常问我,数据结构与算法应该要学习到哪个程度呢?,说实话,这个问题我不知道要怎么回答你,主要取决于你想学习到哪些程度,不过针对这个问题,我稍微总结一下我学过的算法知识点,以及我觉得值得学习的算法。这些算法与数据结构的学习大多数是零散的,并没有一本把他们全部覆盖的书籍。下面是我觉得值得学习的一些算法以及数据结构,当然,我也会整理一些看过
大学四年自学走来,这些私藏的实用工具/学习网站我贡献出来了
大学四年,看课本是不可能一直看课本的了,对于学习,特别是自学,善于搜索网上的一些资源来辅助,还是非常有必要的,下面我就把这几年私藏的各种资源,网站贡献出来给你们。主要有:电子书搜索、实用工具、在线视频学习网站、非视频学习网站、软件下载、面试/求职必备网站。 注意:文中提到的所有资源,文末我都给你整理好了,你们只管拿去,如果觉得不错,转发、分享就是最大的支持了。 一、PDF搜索网站推荐 对于大部
linux系列之常用运维命令整理笔录
本博客记录工作中需要的linux运维命令,大学时候开始接触linux,会一些基本操作,可是都没有整理起来,加上是做开发,不做运维,有些命令忘记了,所以现在整理成博客,当然vi,文件操作等就不介绍了,慢慢积累一些其它拓展的命令,博客不定时更新 顺便拉下票,我在参加csdn博客之星竞选,欢迎投票支持,每个QQ或者微信每天都可以投5票,扫二维码即可,http://m234140.nofollow.ax.
比特币原理详解
一、什么是比特币 比特币是一种电子货币,是一种基于密码学的货币,在2008年11月1日由中本聪发表比特币白皮书,文中提出了一种去中心化的电子记账系统,我们平时的电子现金是银行来记账,因为银行的背后是国家信用。去中心化电子记账系统是参与者共同记账。比特币可以防止主权危机、信用风险。其好处不多做赘述,这一层面介绍的文章很多,本文主要从更深层的技术原理角度进行介绍。 二、问题引入  假设现有4个人
程序员接私活怎样防止做完了不给钱?
首先跟大家说明一点,我们做 IT 类的外包开发,是非标品开发,所以很有可能在开发过程中会有这样那样的需求修改,而这种需求修改很容易造成扯皮,进而影响到费用支付,甚至出现做完了项目收不到钱的情况。 那么,怎么保证自己的薪酬安全呢? 我们在开工前,一定要做好一些证据方面的准备(也就是“讨薪”的理论依据),这其中最重要的就是需求文档和验收标准。一定要让需求方提供这两个文档资料作为开发的基础。之后开发
网页实现一个简单的音乐播放器(大佬别看。(⊙﹏⊙))
今天闲着无事,就想写点东西。然后听了下歌,就打算写个播放器。 于是乎用h5 audio的加上js简单的播放器完工了。 欢迎 改进 留言。 演示地点跳到演示地点 html代码如下`&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;music&lt;/title&gt; &lt;meta charset="utf-8"&gt
Python十大装B语法
Python 是一种代表简单思想的语言,其语法相对简单,很容易上手。不过,如果就此小视 Python 语法的精妙和深邃,那就大错特错了。本文精心筛选了最能展现 Python 语法之精妙的十个知识点,并附上详细的实例代码。如能在实战中融会贯通、灵活使用,必将使代码更为精炼、高效,同时也会极大提升代码B格,使之看上去更老练,读起来更优雅。 1. for - else 什么?不是 if 和 else 才
数据库优化 - SQL优化
前面一篇文章从实例的角度进行数据库优化,通过配置一些参数让数据库性能达到最优。但是一些“不好”的SQL也会导致数据库查询变慢,影响业务流程。本文从SQL角度进行数据库优化,提升SQL运行效率。 判断问题SQL 判断SQL是否有问题时可以通过两个表象进行判断: 系统级别表象 CPU消耗严重 IO等待严重 页面响应时间过长
2019年11月中国大陆编程语言排行榜
2019年11月2日,我统计了某招聘网站,获得有效程序员招聘数据9万条。针对招聘信息,提取编程语言关键字,并统计如下: 编程语言比例 rank pl_ percentage 1 java 33.62% 2 c/c++ 16.42% 3 c_sharp 12.82% 4 javascript 12.31% 5 python 7.93% 6 go 7.25% 7
通俗易懂地给女朋友讲:线程池的内部原理
餐厅的约会 餐盘在灯光的照耀下格外晶莹洁白,女朋友拿起红酒杯轻轻地抿了一小口,对我说:“经常听你说线程池,到底线程池到底是个什么原理?”我楞了一下,心里想女朋友今天是怎么了,怎么突然问出这么专业的问题,但做为一个专业人士在女朋友面前也不能露怯啊,想了一下便说:“我先给你讲讲我前同事老王的故事吧!” 大龄程序员老王 老王是一个已经北漂十多年的程序员,岁数大了,加班加不动了,升迁也无望,于是拿着手里
经典算法(5)杨辉三角
写在前面: 我是 扬帆向海,这个昵称来源于我的名字以及女朋友的名字。我热爱技术、热爱开源、热爱编程。技术是开源的、知识是共享的。 这博客是对自己学习的一点点总结及记录,如果您对 Java、算法 感兴趣,可以关注我的动态,我们一起学习。 用知识改变命运,让我们的家人过上更好的生活。 目录一、杨辉三角的介绍二、杨辉三角的算法思想三、代码实现1.第一种写法2.第二种写法 一、杨辉三角的介绍 百度
腾讯算法面试题:64匹马8个跑道需要多少轮才能选出最快的四匹?
昨天,有网友私信我,说去阿里面试,彻底的被打击到了。问了为什么网上大量使用ThreadLocal的源码都会加上private static?他被难住了,因为他从来都没有考虑过这个问题。无独有偶,今天笔者又发现有网友吐槽了一道腾讯的面试题,我们一起来看看。 腾讯算法面试题:64匹马8个跑道需要多少轮才能选出最快的四匹? 在互联网职场论坛,一名程序员发帖求助到。二面腾讯,其中一个算法题:64匹
面试官:你连RESTful都不知道我怎么敢要你?
面试官:了解RESTful吗? 我:听说过。 面试官:那什么是RESTful? 我:就是用起来很规范,挺好的 面试官:是RESTful挺好的,还是自我感觉挺好的 我:都挺好的。 面试官:… 把门关上。 我:… 要干嘛?先关上再说。 面试官:我说出去把门关上。 我:what ?,夺门而去 文章目录01 前言02 RESTful的来源03 RESTful6大原则1. C-S架构2. 无状态3.统一的接
为啥国人偏爱Mybatis,而老外喜欢Hibernate/JPA呢?
关于SQL和ORM的争论,永远都不会终止,我也一直在思考这个问题。昨天又跟群里的小伙伴进行了一番讨论,感触还是有一些,于是就有了今天这篇文。 声明:本文不会下关于Mybatis和JPA两个持久层框架哪个更好这样的结论。只是摆事实,讲道理,所以,请各位看官勿喷。 一、事件起因 关于Mybatis和JPA孰优孰劣的问题,争论已经很多年了。一直也没有结论,毕竟每个人的喜好和习惯是大不相同的。我也看
SQL-小白最佳入门sql查询一
一 说明 如果是初学者,建议去网上寻找安装Mysql的文章安装,以及使用navicat连接数据库,以后的示例基本是使用mysql数据库管理系统; 二 准备前提 需要建立一张学生表,列分别是id,名称,年龄,学生信息;本示例中文章篇幅原因SQL注释略; 建表语句: CREATE TABLE `student` ( `id` int(11) NOT NULL AUTO_INCREMENT, `
项目中的if else太多了,该怎么重构?
介绍 最近跟着公司的大佬开发了一款IM系统,类似QQ和微信哈,就是聊天软件。我们有一部分业务逻辑是这样的 if (msgType = "文本") { // dosomething } else if(msgType = "图片") { // doshomething } else if(msgType = "视频") { // doshomething } else { // dosho
【图解经典算法题】如何用一行代码解决约瑟夫环问题
约瑟夫环问题算是很经典的题了,估计大家都听说过,然后我就在一次笔试中遇到了,下面我就用 3 种方法来详细讲解一下这道题,最后一种方法学了之后保证让你可以让你装逼。 问题描述:编号为 1-N 的 N 个士兵围坐在一起形成一个圆圈,从编号为 1 的士兵开始依次报数(1,2,3…这样依次报),数到 m 的 士兵会被杀死出列,之后的士兵再从 1 开始报数。直到最后剩下一士兵,求这个士兵的编号。 1、方
致 Python 初学者
文章目录1. 前言2. 明确学习目标,不急于求成,不好高骛远3. 在开始学习 Python 之前,你需要做一些准备2.1 Python 的各种发行版2.2 安装 Python2.3 选择一款趁手的开发工具3. 习惯使用IDLE,这是学习python最好的方式4. 严格遵从编码规范5. 代码的运行、调试5. 模块管理5.1 同时安装了py2/py35.2 使用Anaconda,或者通过IDE来安装模
“狗屁不通文章生成器”登顶GitHub热榜,分分钟写出万字形式主义大作
一、垃圾文字生成器介绍 最近在浏览GitHub的时候,发现了这样一个骨骼清奇的雷人项目,而且热度还特别高。 项目中文名:狗屁不通文章生成器 项目英文名:BullshitGenerator 根据作者的介绍,他是偶尔需要一些中文文字用于GUI开发时测试文本渲染,因此开发了这个废话生成器。但由于生成的废话实在是太过富于哲理,所以最近已经被小伙伴们给玩坏了。 他的文风可能是这样的: 你发现,
程序员:我终于知道post和get的区别
IT界知名的程序员曾说:对于那些月薪三万以下,自称IT工程师的码农们,其实我们从来没有把他们归为我们IT工程师的队伍。他们虽然总是以IT工程师自居,但只是他们一厢情愿罢了。 此话一出,不知激起了多少(码农)程序员的愤怒,却又无可奈何,于是码农问程序员。 码农:你知道get和post请求到底有什么区别? 程序员:你看这篇就知道了。 码农:你月薪三万了? 程序员:嗯。 码农:你是怎么做到的? 程序员:
《程序人生》系列-这个程序员只用了20行代码就拿了冠军
你知道的越多,你不知道的越多 点赞再看,养成习惯GitHub上已经开源https://github.com/JavaFamily,有一线大厂面试点脑图,欢迎Star和完善 前言 这一期不算《吊打面试官》系列的,所有没前言我直接开始。 絮叨 本来应该是没有这期的,看过我上期的小伙伴应该是知道的嘛,双十一比较忙嘛,要值班又要去帮忙拍摄年会的视频素材,还得搞个程序员一天的Vlog,还要写BU
加快推动区块链技术和产业创新发展,2019可信区块链峰会在京召开
      11月8日,由中国信息通信研究院、中国通信标准化协会、中国互联网协会、可信区块链推进计划联合主办,科技行者协办的2019可信区块链峰会将在北京悠唐皇冠假日酒店开幕。   区块链技术被认为是继蒸汽机、电力、互联网之后,下一代颠覆性的核心技术。如果说蒸汽机释放了人类的生产力,电力解决了人类基本的生活需求,互联网彻底改变了信息传递的方式,区块链作为构造信任的技术有重要的价值。   1
程序员把地府后台管理系统做出来了,还有3.0版本!12月7号最新消息:已在开发中有github地址
第一幕:缘起 听说阎王爷要做个生死簿后台管理系统,我们派去了一个程序员…… 996程序员做的梦: 第一场:团队招募 为了应对地府管理危机,阎王打算找“人”开发一套地府后台管理系统,于是就在地府总经办群中发了项目需求。 话说还是中国电信的信号好,地府都是满格,哈哈!!! 经常会有外行朋友问:看某网站做的不错,功能也简单,你帮忙做一下? 而这次,面对这样的需求,这个程序员
网易云6亿用户音乐推荐算法
网易云音乐是音乐爱好者的集聚地,云音乐推荐系统致力于通过 AI 算法的落地,实现用户千人千面的个性化推荐,为用户带来不一样的听歌体验。 本次分享重点介绍 AI 算法在音乐推荐中的应用实践,以及在算法落地过程中遇到的挑战和解决方案。 将从如下两个部分展开: AI 算法在音乐推荐中的应用 音乐场景下的 AI 思考 从 2013 年 4 月正式上线至今,网易云音乐平台持续提供着:乐屏社区、UGC
【技巧总结】位运算装逼指南
位算法的效率有多快我就不说,不信你可以去用 10 亿个数据模拟一下,今天给大家讲一讲位运算的一些经典例子。不过,最重要的不是看懂了这些例子就好,而是要在以后多去运用位运算这些技巧,当然,采用位运算,也是可以装逼的,不信,你往下看。我会从最简单的讲起,一道比一道难度递增,不过居然是讲技巧,那么也不会太难,相信你分分钟看懂。 判断奇偶数 判断一个数是基于还是偶数,相信很多人都做过,一般的做法的代码如下
日均350000亿接入量,腾讯TubeMQ性能超过Kafka
整理 | 夕颜出品 | AI科技大本营(ID:rgznai100) 【导读】近日,腾讯开源动作不断,相继开源了分布式消息中间件TubeMQ,基于最主流的 OpenJDK8开发的
8年经验面试官详解 Java 面试秘诀
    作者 | 胡书敏 责编 | 刘静 出品 | CSDN(ID:CSDNnews) 本人目前在一家知名外企担任架构师,而且最近八年来,在多家外企和互联网公司担任Java技术面试官,前后累计面试了有两三百位候选人。在本文里,就将结合本人的面试经验,针对Java初学者、Java初级开发和Java开发,给出若干准备简历和准备面试的建议。   Java程序员准备和投递简历的实
面试官如何考察你的思维方式?
1.两种思维方式在求职面试中,经常会考察这种问题:北京有多少量特斯拉汽车? 某胡同口的煎饼摊一年能卖出多少个煎饼? 深圳有多少个产品经理? 一辆公交车里能装下多少个乒乓球? 一
相关热词 c#处理浮点数 c# 生成字母数字随机数 c# 动态曲线 控件 c# oracle 开发 c#选择字体大小的控件 c# usb 批量传输 c#10进制转8进制 c#转base64 c# 科学计算 c#下拉列表获取串口
立即提问