Tag Archives: coding

[Solved] AttributeError: ‘_IncompatibleKeys’ object has no attribute

The error code is as follows:

# Error code!
model = model.load_state_dict(state_dict_var)
out = model(input)

There are some problems on the Internet because the saved model uses state_ DCIT() to load, or vice versa.

The error here is different from the above because xxx.load_state_Dict() does not require a return value to receive.

Amend to read as follows:

# Correct code!
model.load_state_dict(state_dict_var)
out = model(input)

I hope it will help more people.

Solution of Unicode decodeerror -‘utf-8 ‘codec can’t decode byte 0xc4 in position 0 – invalid continuation byte


Reading CSV document with Pandas is an error that cannot be read because there is Chinese in the document. The error is due to the failure of the 'utf-8' codec to decode the 0 bit byte 0xc4

Solutions:
After reading the file, add encoding=’ GBK ‘,
such as: pddata=pd. Read_csv (' felipe.csv ',encoding=' GBK ')


Interested to continue to see the reason!
As you know, the default encoding we use in Python is UTF-8. For an introduction to coding, I recommend taking a look at Liao Da’s Python tutorial, “Strings and Coding.” Since UTF-8 format cannot correctly read CSV files with Chinese characters, it would be a good idea to select a format that can read Chinese characters.
So what format can read Chinese characters?We open the Python3 official website: find the section on standard characters. The diagram below:

So what format do you want to change?You can see that the third column of the table, Language, represents what Language the encoding supports. So let’s find out.
!
I’m not going to show you the table here, but if you’re interested, go to the website. Anyway, under my careful search, there is big5; Big5hkscs; Gb2312; GBK; Gb18030. Hz; The five formats iso2022_jp_2 may support Chinese. After my test, I found gb2312; GBK; Gb18030 can read CSV files with Chinese smoothly. (Since all three are ok, let’s have a good GBK.)

It works!

Ubuntu can’t open Gnome terminal and display the error message exited status 8

I’ve been playing around with some environments for my virtual machine lately, and since I don’t have much experience, I’m just following the path of the server. However, once the virtual machine is restarted later, something goes wrong. The GNOME terminal cannot be opened. Start gnOMe-Terminal using Xterm.
Error constructing proxy for org.gnome.Terminal:/org/gnome/Terminal/Factory0: Error calling StartServiceByName for org.gnome.Terminal: GDBus.Error:org.freedesktop.DBus.Error.Spawn.ChildExited: Process org.gnome.Terminal exited with status 8

The next time I look it up, it’s a coding problem. Just use the command sudo DPkg-reconfigure locales to add the code you want.

You think that’s the end of it?If you didn’t solve it, it should be the same problem I encountered. I accidentally found that when I configured the environment for my virtual machine, I actually configured another statement: export LC_ALL=C. In this way, no matter how I configured my code, I could not open the terminal in any way.

I finally get rid of that, and the locale in the terminal, works!