Search
 
SCRIPT & CODE EXAMPLE
 

CPP

how to find the mean and standard deviation of trqiing dataset in pytorch

def mean_std(loader):
    mean = 0.0
    std = 0.0
    total_images_count = 0
    for images, _ in loader:
        image_count_in_a_batch = images.size(0)
        images = images.view(image_count_in_a_batch, images.size(1), -1)
        mean += (images * 1.0).mean(2).sum(0)
        std += (images * 1.0).std(2).sum(0)
        total_images_count += image_count_in_a_batch
    mean /= total_images_count
    std /= total_images_count
    return mean, std

(tensor([112.1058, 126.2224,  79.7943]), tensor([49.5487, 50.0356, 43.0908]))
Comment

PREVIOUS NEXT
Code Example
Cpp :: Configuring an c++ OpenCV project with Cmake 
Cpp :: android call custom managed method from native code 
Cpp :: The program must enter a natural number n from the console and find the number previous to n that is not divisible by 2 , 3 and 5 . 
Cpp :: MPI_File_seek 
Cpp :: c++ negate boolean 
Cpp :: C++ 4.3.2 (gcc-4.3.2) sample 
Cpp :: simple interest rate 
Cpp :: return value optimization example 
Cpp :: error when using template base class members 
Cpp :: assoc-right antlr 
Cpp :: compile c++ MPI Program 
Cpp :: write c++ code using glbegin and gland() function 
Cpp :: if c++ 
Cpp :: c++ is nan 
Cpp :: binpow in fenwick tree 
Cpp :: C++ Area and Circumference of a Circle 
Cpp :: void pointer c++ 
Cpp :: can derived class access private members 
Cpp :: c++ forloop 
C :: trie tableau c 
C :: how to store a user input with spaces in c 
C :: c string is int 
C :: golden cobblestone modpack 
C :: c data types 
C :: Calculator_C 
C :: get current used proxy windows 7 
C :: c integer to string 
C :: ROUNDING decimal number in C 
C :: how to scan in c 
C :: limit axis in one direction plt 
ADD CONTENT
Topic
Content
Source link
Name
3+8 =