2020年1月14日星期二

Method to get all attributes of a Python object

In order to get all the attributes of a Python object, we only need to do the following:

dir(obj)

1only batches of spatial targets supported (non-empty 3D tensors) but got targets of size: :

I encountered the above problem when using Pytorch's CrossEntropy function.

E.g:
criterion = nn.CrossEntropyLoss()

loss = criterion(logit, target.long())
If logit.shape is torch.Size ([4, 31, 256, 256])  and target.shape is [4, 256, 256, 1], where 4 is the batchSize and 31 is the number of categories.

The error 1only batches of spatial targets supported (non-empty 3D tensors) but got targets of size:: will appear.

2020年1月5日星期日

FIFO over run error TCSPC (Pico Harp 300)

FIFO over run error in time-dependent single photon counter (model PicoHarp300) in continuous measurement mode

Reason: There are relevant instructions in the manual. In summary, there are too many photons and it is impossible to record in real time;

Solution: Turn down the laser power to reduce the number of photons per unit time.

Installation of scanning galvanometer GAS012 and GVS012

Step1: Remove the three hex screws on the side of GVS012

Step2: Align the three holes on the side of GAS012 with the three holes on the side of GVS012;

Step3: Screw the three hexagonal screws back on.

Step4: You can use the M4 / M6 screws to fix GAS012 to the optical tablet.

Image .save FileNotFoundError: [Errno 2] No such file or directory: '../Dataset/testResults/5.png'

Because it is .save, the reason is obviously not that there is no "../Dataset/testResults/5.png" file.

It is:

No ../Dataset/testResults/ directory

Example:


  1. This directory has not been created
  2. typo in the directory
  3. use Chinese or other characters.



After confirming that the directory is correct, the error is resolved.

ssh upload file to server

When there is a problem with the winsshfs mount file, you can directly use ssh to upload it, as follows:

scp ./1229.zip username@servername:~/

Python: divide a folder into small folders

Assume that there are 10,000 pictures in a large folder. This code is used to divide the 10,000 pictures into 9 subfolders according to the characteristics of the file name:

dir_sum   
    --dir1
    --dir2
    ...
    --dir9