Tag Archives: bug

RuntimeError: Integer division of tensors using div or / is no longer supported, and in a future rel

RuntimeError: Integer division of tensors using div or/is no longer supported, and in a future release div will perform true division as in Python 3. Use true_divide or floor_divide (// in Python) instead.

from torchvision import transforms
import numpy as np

data = np.random.randint(0, 255, size=12)
img = data.reshape(2, 2, 3)
print(img.shape)
img_tensor = transforms.ToTensor()(img)  # Convert to tensor
print(img_tensor)
print(img_tensor.shape)
print("*" * 20)
norm_img = transforms.Normalize((10, 10, 10), (1, 1, 1))(img_tensor)  # Perform normative processing
print(norm_img)

Operation effect:

reason:

Pytorch1.5.0 is OK, but when upgrading to 1.6.0, it is found that division between tenor and int cannot be directly performed with ‘/’.

Solution:

Standardize the data processing

Example code:

from torchvision import transforms
import numpy as np

data = np.random.randint(0, 255, size=12)
img = data.reshape(2, 2, 3)
print(img.shape)
img_tensor = transforms.ToTensor()(img)  # convert to tensor
print(img_tensor)
print(img_tensor.shape)
print("*" * 20)
img_tensor = img_tensor.float()  # Add this line
norm_img = transforms.Normalize((10, 10, 10), (1, 1, 1))(img_tensor) # Perform normalization
print(norm_img)

Results of operation:

How to Solve Error: Driver “kvm2“ not found

This error occurred in the environment of Ubuntu 16.04. According to the official KVM installation mode, starting minicube still reported an error

curl -LO https://storage.googleapis.com/minikube/releases/v0.30.0/docker-machine-driver-kvm2
chmod +x docker-machine-driver-kvm2
sudo mv docker-machine-driver-kvm2 /usr/local/bin/

As above, after installing docker-machine-driver-kvm2 (note that the version should not be too new)

[Solved] Illegal access: this web application instance has been stopped already

The environment at that time:

When testing the UAT project, I suddenly found that the project could not be accessed normally. In fact, there are many times when the project is still in good condition in the last second and explodes in the next second. It’s very uncomfortable, especially when testing the joint debugging

So he opened the log with curiosity and found that the original report was wrong

java.lang.IllegalStateException: Illegal access: this web application instance has been stopped already.
 
Could not load [java.beans.PropertyChangeEvent]. The following stack trace is thrown for debugging 

purposes as well as to attempt to terminate the thread which caused the illegal access.

His general meaning is that the web application has stopped and can’t load something called XXXXXXXX.

Then kill the Tomcat process, and then get up
to solve the problem….

be careful:

if you restart tomcat, you cannot solve the problem.
to modify the server.xml , add a child element to the tag, find the tag, and set the attribute value of reloadable to reloadable = false.

It means hot deployment, which is convenient for developers

A little bug of CSDN blog

Recently, when editing the blog, I found a small flaw in CSDN, which should not be a bug, but if I don’t pay attention, it may also bring a lot of trouble to users.

Hyperlinks are sometimes used when editing blogs. When adding hyperlinks, the interface of CSDN is as follows:

Users can enter their own link address in the link address column, but please note that the “http://” field is selected by default, that is, if you copy a link address and want to paste it into this column, you will erase the “http://” field, leaving only your own pasted address.

And in practice, the probability is very high.

What’s the difference between HTTP and no HTTP?

From the perspective of users, they don’t want to make a difference, but in practice, there is a big difference between HTTP and no http.

There is no HTTP at the beginning. The browser will treat the link as a relative address by default, that is, the address relative to the current address“ blog.csdn.net/waitig1992/article/details/ ”Add the address you entered after this address.

But most users don’t want this result. They just want the browser to jump to the link they input, which leads to the lack of user experience.

Some people will say: those who publish articles on CSDN are all technical giants. They should know these problems and can avoid them by themselves. They can modify them by themselves.

But all things can’t be solved by users themselves. Moreover, with the fierce competition, some small details may determine the success or failure of the enterprise.

And not everyone has noticed.

On the contrary, baidu space noticed this detail, its hyperlink input box does not have “http://”, but automatically detects changes after users edit. As shown in the figure:

After editing, it will automatically detect and modify, and add “http://”, as shown in the figure:

In this way, users don’t have to care whether they write “http://”, but can focus more on their own articles.

That’s the details.

Appendix:

This link has “http://” blog.csdn.net/waitig1992

There is no http:// blog.csdn.net/waitig1992

You can click to see the difference;

I hope CSDN official can pay attention to this problem, and I will also send email feedback.

Finally, I wish CSDN more and more fire, you can all think of it!

Klee Error: Assertion `userMainFn && “unable to get user main“‘ failed

Problem
klee reports an error.

klee: /tmp/klee_src/tools/klee/main.cpp:1068: void createLibCWrapper(std::vector<std::unique_ptrllvm::Module >&, llvm::StringRef, llvm::StringRef): Assertion `userMainFn && “unable to get user main”’ failed.

Cause
The test code added ifdef INCLUDEMAIN, which caused the main function to be skipped and triggered klee’s assertion.

#ifdef INCLUDEMAIN
int main 
.....
.....
#endif

solve

Just comment out those two lines.

Debug | AttributeError: ‘numpy.int64‘ object has no attribute ‘to_pydatetime‘

reason

When using pyfolio , we encountered the following errors:

/usr/local/lib/python3.7/dist-packages/pyfolio/ timeseries.py in gen_ drawdown_ table(returns, top)
1006 recovery,
1007 freq=‘B’))
-> 1008 df_ drawdowns.loc [i, ‘Peak date’] = ( peak.to_ pydatetime()

AttributeError: ‘ numpy.int64 ’ object has no attribute ‘to_ pydatetime’

analysis

Confused, is very confused, after all, the transfer of a problem is also very uncomfortable.
search online, pyfoliogithub issues also has many people make complaints about this problem, such as #520, #652, #653, but more people are same error, no solution. 😦

Solution

Many solutions have been found on the Internet. They have tried one by one. Only the last one works well. Everyone can try it

s1 (Failed)

The /usr/local/lib/python3.7/dist-packages/pyfolio/ timeseries.py 893 line changed to

valley = underwater.index[np.argmin(underwater)] # end of the period

It’s no use, continue to change:

s2 (Failed)

The *. To_ Pydatetime() change to this

pd.to_datetime(peak)
pd.to_datetime(valley
pd.to_datetime(recovery)

Failure, and then repeatedly change those lines of code in the reference websites, mainly for the function that reported the error and def get_ max_ drawdown_ Underwater (underwater):
the code in
failed. It’s better to find a solution without changing the code:

sn (Success)

If we install it in PIP install pyfolio , then we uninstall and install it in GIT. Maybe it’s the latest version or something. In the end, this is the solution:

!pip uninstall pyfolio  # uninstall
!pip install git+https://github.com/quantopian/pyfolio # reinstall

After unloading, restart the code, or del pyfolio Import pyfolio , it is recommended to restart
and then run it again ~
finally, it’s out of the question:

A JavaScript error occurred in the main process

A JavaScript error occurred in the main process

Running your own software (bonebd) after packaging and installing, an error is reported:

recompiling code also cannot be opened.

Search the% appdata% folder, find the (bonebd) folder and delete it.

Recompile program runs correctly.

Reason:
it may be caused by incomplete software installation, which can be solved by forcibly removing the cache file of the software on the system.

Keytool error: java.io.FileNotFoundException : MyAndroidKey.keystore (access denied)

This is the problem I encountered when I used java keytool to generate certificates this afternoon

Cause error:

Keytool error: java.io.FileNotFoundException : MyAndroidKey.keystore (access denied)

Analyze the problem:

When the certificate is generated, the permissions are not enough when writing to disk C. The properties of all the directories under C disk are read-only.

terms of settlement:

Method 1:
the path of JDK is in disk C. you can move JDK to other disk letters.
Method 2:
this method is the simplest to open CMD as an administrator, so that the error will not occur when writing something.

[error] attributeerror: module ‘SIP’ has no attribute ‘setapi‘

Problem Description:

Import bar_ chart_ Race report error

Recently, I was importing bar_ chart_ Error: attributeerror: module 'SIP' has no attribute 'setapi'
imported package:

import bar_chart_race as bcr

Just run the imported statement and an error will be reported: attributeerror: module 'SIP' has no attribute 'setapi'

terms of settlement:

Finally, I found that the reason for this error is that the version of Matplotlib library is too high. The version I reported is 3.3.2. If I downgrade it to 3.3.0, there will be no problem;

Uninstall first: PIP install Matplotlib

Re install: PIP install Matplotlib = = 3.3.0

Problem solving!!

Solution of running error reporting attributeerror: ‘rectangle’ object has no property ‘normalized’

Have a problem

When running the code, the following error prompt appears:

AttributeError:'Rectangle' object has no property 'normed'

resolvent

The reason is that the library has been updated and there is no such attribute. Delete the normal in the code (no error, but it seems that it can’t be drawn)

Replace the normal attribute in the code with density , and add an attribute stacked = true .


Thank you for your comments.

Python reported an error with keyerror: ‘longitude’

The error reporting interface of Python is shown in the following figure:
. I found a solution on the Internet, which may be useful to you. But I tried it, but it didn’t work. So when I looked at it, I found that it was caused by my carelessness. Ah, as shown in the figure below, there is a comma missing in front of longitude, as shown in the figure below:
, so this problem is solved. OK, I will continue my course design.