Error records encountered in PyTorch learning and TensorFlow learning

1. TypeError: not all arguments converted during string formatting

This is a problem that the parameter type does not correspond to. It appears when passing parameters with %.
Solution:
Replace% with .format().

2. When PyTorch uses TensorboardX to visualize, the url cannot be accessed problem

The command used is: tensorboard --logdir Jul22_18-03-19_WH-PC19012AlexNet
The URL that appears is: TensorBoard 1.14.0 at http://DESKTOP-UTFSE8L:6006/ (Press CTRL+C to quit)
and this url cannot be accessed.
Solution: This is due to the version and cannot be directly visualized with port 6006.
Change the command to: tensorboard --logdir=path where the runs folder is located --host=127.0.0.1
For example:
tensorboard --logdir=E:\Pycharm\project\project_pytorch.idea --host=127.0.0.1
After running, The generated URL can normally access the visual structure of pytorch's network model.

3. Use TensorFlow2.0 to run the program and report an error: ValueError: TypeError: len() of unsized object

This is caused by the numpy version being too high and incompatible with tensorflow2.0. I use numpy 17.0.0 version, downgraded to 1.16.4 version.
pip install numpy == 1.16.4

4. When using PyTroch, the previous program cannot be used, and an error is reported: ImportError: cannot import name'PILLOW_VERSION' from'PIL'

This is because the pillow was updated to 7.0.0 two days ago, which caused a mismatch. The 7.0.0 version does not have the value of PILLOW_VERSION and needs to be downgraded.
Uninstall pillow first, pip uninstall pillow
and then specify the version pip install pillow==6.1.0
to run again, it can run normally

5. When using the conda command to install the third-party library, it fails to install and an error occurs: RemoveError:'setuptools' is a dependency of conda and cannot be removed from conda's operating environment

You can try the following two methods:

  1. conda update --force conda
  2. conda install -c anaconda setuptools

6. A warning appears when running the tensorflow program: Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2

This is just a warning and generally has no effect. You can choose to ignore it, or you can block this warning with the following code:

import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'

There is no warning after running

7. An error occurs when running the tensorflow program: OSError: Unable to open file (truncated file: eof = 417792, sblock->base_add...

This is because the previously downloaded model is not completed and cannot be opened. You need to delete the previously downloaded model and download again to continue. The path is: C:\Users\adminPC.keras\models

8.TypeError: ‘tuple’ object is not callable

This is due to the shape error, it should be img.shape[0] or img.shape can display the array size.

9. Use opencv to read in the picture, matplotlib's pyplot shows that the color of the picture is abnormal

This is because opencv reads pictures in BGR format, while pyplot displays pictures in RGB format, so inverted colors may occur. Solution:
Use opencv's cvtColor function to convert and display. .

image = cv2.cvtColor(img,cv2.COLOR_BGR2RGB)
plt.imshow(image)

10. Warning when using tensorflow GPU version: CUDNN_STATUS_ALLOC_FAILED

This is because only one program can be run with gpu at the same time, and other programs should be closed. .

Guess you like

Origin blog.csdn.net/weixin_45371989/article/details/103298963