Posts

Semantic Segmentation

Image
Adapt from  https://www.jeremyjordan.me/semantic-segmentation/ The goal of semantic image segmentation is to label each pixel of an image with a corresponding class of what is being represented. Because we're predicting for each pixel in the image, this task is commonly referred to as dense prediction. Earlier layers tend to learn low-level concepts while later layers develop more high-level feature mappings. Drozdzal et al.   swap out the basic stacked convolution blocks in favor of residual blocks. This residual block introduces short skip connections alongside the existing long skip connections between the corresponding feature maps of encoder and decoder modules found in the standard U-Net structure. The report that the short skip connections allow for faster convergence when training and allow for deeper models to be trained. Expanding on this, Jegou et al. proposed the use of dense blocks, still following  a U-Net structure,  arguing that the "characte...

Few-Shot Class-Incremental Learning

Paper from: https://arxiv.org/pdf/2004.10956.pdf Incremental learning new classes Few-shot class-incremental learning problem(FSCIL) FSCIL requires CNN models to incrementally learn new classes from very few labelled samples. Topology-perserving knowledge incrementer framework(TOPIC) To mitigate forgetting, most class-incremental learning(CIL) works use the knowledge distillation technique that maintains the network's output logins correspond to old classes. They usually store s set of old class exemplars and apply the distillation loss to the network's output. Problems: 1)class-imbalance problem; 2)performance trade-off between old and new classes TOPIC uses a neural gas(NG) network to model the topology of feature space.  When learning the new classes, NG grows to adapt to the change of feature space. On this basis, we formulate FSCIL as an optimization problem with two objectives.  1) to avoid catastrophic forgetting, TOPIC preserves the old...

Java Learning

Java 注解: Java 语言中的类、方法、变量、参数和包都可以被标注。 Java标注可以通过反射获取标注内容。 内置的注解: Java定义了一套注解,共有7个,3个在java.lang中,剩下的4个在java.lang.annotation中。 @override--检查该方法是否是重写方法。如果发现其父类,或者引用的接口并没有该方法时,会报编译警告。 @Deprecated--标记过时方法。如果使用该方法,会报编译警告。 @SupperessWarning--指示编译器去忽略注解中声明的警告。 @Retention--标识这个注解应该怎么保存,是只在代码中,还是编入class文件中,或者是在运行时间可以通过反射访问。 @Documented--标记这些注解是否包含在用户文档中。 @Target--标记这个注解应该是哪种Java成员。 @Inherited--标记这个注解是继承于哪个注解类。

Daily-coding-problem #101

# This problem was asked by Alibaba. # Given an even number (greater than 2), return two prime numbers whose sum will be equal to the given number. def is_prime(n, primes):     for p in primes:         if n == p:             return True         if not n%p == 0:             return False     return True def get_primes(num):     limit = num//2     primes = list()     candidates = list()     for i in range(2, limit+1):         if is_prime(i, primes):             primes.append(i)             candidates.append((i, num-i))     new_candidates = list()     for p1, p2 in candidates[::-1]:         if is_prime(p2, primes):             primes.append(p2)     ...

Image Similarity using Deep Ranking

Image
Image similarity: the measure of how similar two images are. In other words, it quantifies the degree of similarity between intensity patterns in two images. Triplet: a triplet contains a query image, a positive image and a negative image. How to measure the similarity of two images? L1-norm: Manhattan distance L2-norm: Euclidean distance Loss function: The whole deep ranking architecture can be thought of as a function that would map the image to a point in the Euclidean space. The goal is to learn an embedding function that assigns smaller distance to more similar images. D(f(pi), f(pi+)) < D(f(pi), f(pi-)) <pi, pi+, pi-> such that r(pi, pi+) > r(pi,pi-) f is the embedding function that would map the image to a vector. pi is the query image, pi+ is the positive image, pi- is the negative image and r is the similarity distance between two images. The hinge loss for the triplet is defined as: l(pi, pi+, pi-) = max{0, g+D(f(pi), f(pi+)) - D(f(pi),f(pi-...

Python Notes

zip: returns a list of tuples, where the i-th tuple contains the i-th element from each of the argument sequences or iterables. a = [1, 2, 3] b = ['a', 'b', 'c'] for i, j in zip(a, b):      print(i,j) =>1 a =>2 b =>3 c Python __repr__() function returns the object representation. It could be any valid python expression such as tuple, dictionary, string etc.  id(object): return the "identity" of an object. This is an integer which is guaranteed to be unique and constant for this object during its lifetime. Two objects with non-overlapping lifetimes may have the same id() value. hasattr() The hasattr() method returns true if an object has the given named attribute and false if it does not. hasattr(object, name) PIL. Image.resize(size, resample = 0) returns a resized copy of this image Parameters:  -size: the requested size in pixels, as a 2-tuple -resample: an optional resampling filter. This can be one of PIL.I...

Pytorch Notes

torch.nn.functioanl.adaptive_avg_pool2d(input, output_size) Applies a 2D adaptive average pooling over an input signal composed of several input planes. torch.nn.functional.adaptive_avg_pool3d(input, output_size) Applies a 3D adaptive average pooling over an input signal composed of several input planes Class: torch.nn.Parameter A kind of Tensor that is to be considered a module parameter. parameters: data(Tensor) torch.nn.functional.interpolate(input, size, scale_factor, mode= 'nearest', align_corners) Down/up samples the input to either the given size or the given scale_factor. The algorithm used for interpolation is determined by mode. torch.cat(tensors, dim = 0, out = None) concatenates the given of seq tensors in the given dimension. All tensors must be either have the same shape or be empty.