1 / 70

Nauka bez nauczyciela : Autoencoder y i Analiza Składowych Głównych

Nauka bez nauczyciela : Autoencoder y i Analiza Składowych Głównych. Inteligentne Systemy Autonomiczne. W oparciu o wyklad Prof. Geoffrey Hinton University of Toronto. Janusz A. Starzyk Wyzsza Szkola Informatyki i Zarzadzania w Rzeszowie.

fryerg
Download Presentation

Nauka bez nauczyciela : Autoencoder y i Analiza Składowych Głównych

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Nauka bez nauczyciela: AutoencoderyiAnaliza Składowych Głównych Inteligentne Systemy Autonomiczne W oparciu o wyklad Prof. Geoffrey Hinton University of Toronto Janusz A. Starzyk Wyzsza Szkola Informatyki i Zarzadzania w Rzeszowie

  2. Analiza Składowych Głównych(ang. Principal Components Analysis) • PCA obejmuje obliczenia dekompozycji wartosci osobliwych (singular value decomposition) macierzy danych, zwykle po odjeciu wartosci sredniej każdego atrybutu • Następnie dane są przekształcane używając • i otrzymując macierzdanychYw zredukowanej przestrzeni poprzez odwzorowanie Xdo przestrzeni o zredukowanych wymiarchzdefiniowanej tylko przez pierwszychMwektorow osobliwych, WM

  3. Analiza Składowych Głównych • Bierze N-wymiarowe dane i znajduje M ortogonalnych kierunkow, w ktorych dane mają największa zmiennosc • Te M-głównych kierunków tworzy podprzestrzeń. • Możemy reprezentować N-wymiarowy wektor danych przez jego rzutowanie na M-głównych kierunkow. • To traci wszystkie informacje o tym gdzie wektor danych jest zlokalizowany w pozostałych kierunkach ortogonalnych. - Odtwarzamy ta informacje używając wartości średniej (po wszystkich danych) w N-M kierunkach, które nie są reprezentowane. • Błąd rekonstrukcji jest sumą po tych wszystkich niereprezentowanych kierunkachkwadratow różnic odległości od wartosci średnich.

  4. Ilustracja PCA przy N=2 i M=1 Czerwony punkt jest reprezentowany przez zielony punkt. Nasza „rekonstrukcja” czerwonego punktu posiada błąd równy kwadratowi odległości między zielonym a czerwonym punktem. Pierwsza skladowa główna: Kierunek największej zmienności

  5. Grupowanie (Clustering) • Zakładamy że dane zostały wygenerowane z kilku różnych klas. Celem jest aby zgrupowanie danych z tej samej klasy razem. • Jak decydujemy o liczbie klas? • Dlaczego nie umieszczać kazdego wektora danych w oddzielnej klasie? • Jaki jest zysk z grupowania rzeczy razem? • Co jeśli klasy są hierarchiczne? • Co jeżeli każdy wektor danych może zostać sklasyfikowany na różne sposoby? • W klasyfikacjijeden-z-N nie ma tyle informacji cow wektorze cech.

  6. Zakładamy że dane żyją w przestrzeni Euklidesowej Zakładamy że chcemy k klas. Zakładamy, że zaczynamy od przypadkowo rozmieszczonych środków klasterów Algorytm jest przełącza się kolejno między dwoma krokami: Krok przypisania: Przydziel każdy punkt odniesienia do najbliższego klastera. Krok dopasowujący: Przesuń środek każdego klastera do środka ciężkości przydzielonych mu danych. Algorytm k-wartosci średnich Przypisania Dopasowane średnich

  7. Dlaczego k-wartosci średnich zbiega się • Gdy tylkoprzypisanie jest zmienione, suma kwadratow odległości wektorow danych od środków przypisanych klasterów zmniejsza sie. • Gdy tylko środek klastera jest przesuniętywtedy suma kwadratow odległości wektorow danych od środków aktualnie przypisanych im klasterów zmniejsza sie. • Jeśli przynależności nie ulegają zmianie w kroku przypisania, mamy zbieżność.

  8. Nie ma nic co by zabezpieczyło k-środków od ugrzazniecia w lokalnym minimum. Moglibyśmy spróbować wiele przypadkowych punktów startowych Moglibyśmy spróbować połączyćdwasąsiednie klastery ipodzielićduży klaster na dwa. Złe lokalne optimum Lokalne minimum Moglibyśmy użyć informacji o lokalnej gęstości aby łączyć i dzielić klastery.

  9. Generujący model mieszanek Gaussowskich (The mixture of Gaussians generative model) • Najpierw wybierzjeden z krozkładów Gaussaz prawdopodobieństwem, nazywanym „proporcją mieszania”. • Potem wygeneruj punkt przypadkowy z wybranego rozkładu. • Prawdopodobieństwo wygenerowania dokładnych danych, które zaobserwowaliśmy jest zero, ale nadal możemy spróbować zmaksymalizować gęstość prawdopodobieństwa. • Dopasować wartości średnie rozkładów Gaussa • Dopasować zmienności rozkładóww każdym wymiarze • Dopasować proporcjemieszania rozkładów.

  10. Generujący model mieszanek Gaussowskich • 500 punktów wygenerowanych z mieszanki 3 rozkładów Gaussa • a) próbki 3 klas (3 kolorów) • b) te same próbki z oznaczonymi wartościami przynależności

  11. Krok oczekiwania (expectation E): Obliczanie odpowiedzialności A priori i-tego rozkladu A posteriori i-tego rozkladu • Aby dostosować parametry, musimy najpierw rozwiązać problem wnioskowania: Która rozkład Gaussa wygenerował, który wektor danych? • Nie możemy być pewni więc jest to rozkład na wszystkie możliwości. • Użyj twierdzenia Bayesaaby uzyskać prawdopodobieństwaa posteriori Twierdzenie Bayesa Proporcje mieszania Iloczyn po wszystkich wymiarach danych

  12. Krok maksymalizujący (M):Obliczanie nowych proporcji mieszania • Każdy Gaussian otrzymuje pewne prawdopodobieństwo a posteriori dlakażdego wektora danych. • Optymalna proporcja mieszania do uzycia (dająca te prawdopodobieństwa a posteriori) jest tylko ułamkiem danych za które Gaussian bierze odpowiedzialność. A posteriori i-tego rozkladu Dane treningowe c Liczba danych treningowych

  13. Więcejo kroku M: Obliczanie nowych średnich • Obliczamy tylko środek ciężkości danych za które rozkład Gaussa jest odpowiedzialny • Dokładnie jak w K-średnich, tylko że dane są ważone przez prawdopodobieństwaa priori rozkładów Gaussa. • Gwarantowane położenie w wypukłym obrębie danych • Moze być duży skok poczatkowy

  14. Więcejo kroku M: Obliczanie nowych wariancji • Dopasowujemy zmienność każdego rozkładu Gaussa, i, w każdym wymiar, d, do danych warzonych prawdopodobieństwem a posteriori • Jest to bardziej skomplikowane jeśli używamy rozkładu Gaussa o pełnej kowariancji, która nie jest ułożona wzdloz osi wymiarow.

  15. Jak wiele rozkładów Gaussa używamy? • Zatrzymaj zbiór danych walidacji • Spróbuj różne liczbyrozkladow • Wybierz liczbektóra dajenajwiększą gęstość prawopodobienstwa dla zbioru walidacji. • Uściślenie: • Moglibyśmy zrobić mniejszy zbiór walidacjiprzez używanieróżnych innych zbiorów walidacjii uśrednienie wydajności. • Powinniśmy użyć wszystkich danych do treningu końcowego parametrów, po tym jak zdecydowaliśmy się na najlepszą liczbę rozkładów Gaussa

  16. Unikanie lokalnych optimów • EM może być łatwo zablokowany w lokalnym optimum. • To pomaga wystartować z bardzo rozległymi rozkładami Gaussaktóre są wszystkie bardzo podobne i tylko stopniowo zmniejszać wariancje. • W miarce redukcji wariancji, rozkładyrozciągają się wzdłuż pierwszej głównej składowejdanych.

  17. Mieszanki Ekspertów • Czy możemy zrobić coś lepszego niż tylko uśrednianie predykatorów w sposób niezależny od szczególnego przypadku treningowego? • Możemy popatrzeć na dane wejściowe dla szczególnego przypadku aby zdecydować się na jakiś model • To może prowadzić do specjalizacji modeli do podzbioru danych treningowych • One nie uczą się na przypadkach do których nie zostały wybrane.Więc mogą ignorować rzeczy, których nie umieją modelować. • Kluczową ideą jest aby każdy ekspert skupił sie na przewidywaniu właściwej odpowiedzi dla przypadków, w których wykonuje to już lepiej niż inni eksperci. • To wywołuje specjalizację. • Jeśli zawsze uśredniamy wszystkie predykatory, to każdy model próbuje zrekompensować połączony błąd wytworzony przez wszystkie inne modele.

  18. Tworzenie funkcji błędu która pobudza specjalizację zamiast współpracy Średnia wszystkich predyktorów • Jeśli chcemy zachęcić do współpracy, porównujemy średnią wszystkich predyktorów z celem i szkolimy aby zredukować rozbieżność • To może prowadzić do ogromnego przetrenowania. To czyni model silniejszym niż trenowanie każdego predykatora oddzielnie. • Jeśli chcemy pobudzić specjalizację porównujemy każdy predykator oddzielnie z celem i trenujemy aby zredukować średnią wszystkich tych niezgodności. • Najlepiej jest używać średniej ważonej, gdzie wagi, p, są prawdopodobieństwem wybierania „eksperta” dla danego przypadku prawdopodobieństwo wyboru eksperta i dla tego przypadku

  19. Architektura mieszanki ekspertów Połączony predykator: Prosta funkcja błędu dla treningu: (Jest lepsza funkcja błędu) Ekspert 1 Ekspert 2 Ekspert3 Siec progowa Softmax wejście

  20. Pochodne prostej funkcji kosztu • Jeśli zróżniczkujemyze względu nadane wyjściowe ekspertów, otrzymamy sygnał dla trenowaniakażdego eksperta. • Jeśli zróżniczkujemyze względu nadane wyjściowesieci progowejotrzymamy sygnał do uczeniasieci progowej. • Chcemy zwiększać p dla wszystkich ekspertów, którzy dają mniej niż średnia kwadratów błędów wszystkich ekspertów (ważonych przez p)

  21. Minimalizacja kwadratu bledow jest równoważna z maksymalizowaniem logarytmu prawdopodobieństwa poprawnych odpowiedzi przy rozkładzie Gaussa skoncentrowanym na predykcji modelu Jeśli złożymy, że wariancje rozkładów Gaussasa takie same dla wszystkich przypadkow, to jej wartość nie ma znaczenia. Dystrybucja prawdopodobieństwa, która jest domyślnie przyjęta gdy używamy kwadratu błędu y predykcja modelu d poprawna odpowiedz

  22. Pytania?

  23. Learning without a teacher: Autoencoders and Principal Components Analysis Pelna wersja

  24. Three problems with backpropagation • Where does the supervision come from? • Most data is unlabelled • The vestibular-ocular reflex is an exception. • How well does the learning time scale? • Its is impossible to learn features for different parts of an image independently if they all use the same error signal. • Can neurons implement backpropagation? • Not in the obvious way. • but getting derivatives from later layers is so important that evolution may have found a way. y w1 w2

  25. Three kinds of learning • Supervised Learning: this models p(y|x) • Learn to predict a real valued output or a class label from an input. • Reinforcement learning: this just tries to have a good time • Choose actions that maximize payoff • Unsupervised Learning: this models p(x) • Build a causal generative model that explains why some data vectors occur and not others or • Learn an energy function that gives low energy to data and high energy to non-data or • Discover interesting features; separate sources that have been mixed together; find temporal invariants etc. etc.

  26. The Goals of Unsupervised Learning • Without a desired output or reinforcement signal it is much less obvious what the goal is. • Discover useful structure in large data sets without requiring a supervisory signal • Create representations that are better for subsequent supervised or reinforcement learning • Build a density model that can be used to: • Classify by seeing which model likes the test case data most • Monitor a complex system by noticing improbable states. • Extract interpretable factors (causes or constraints) • Improve learning speed for high-dimensional inputs • Allow features within a layer to learn independently • Allow multiple layers to be learned greedily.

  27. Try to make the output be the same as the input in a network with a central bottleneck. The activities of the hidden units in the bottleneck form an efficient code. The bottleneck does not have room for redundant features. Good for extracting independent features (as in the family trees) Using backprop for unsupervised learning output vector code input vector

  28. Self-supervised backprop in a linear network • If the hidden and output layers are linear, it will learn hidden units that are a linear function of the data and minimize the squared reconstruction error. • This is exactly what Principal Components Analysis does. • The M hidden units will span the same space as the first M principal components found by PCA • Their weight vectors may not be orthogonal • They will tend to have equal variances

  29. Principal Components Analysis • PCA involves the computation of the singular value decomposition of a data matrix, usually after mean centering the data for each attribute. • After that Data is transformed using • and then obtaining the reduced-space data matrix Y by projecting X down into the reduced space defined by only the first M singular vectors, WM

  30. Principal Components Analysis • This takes N-dimensional data and finds the M orthogonal directions in which the data has the most variance • These M principal directions form a subspace. • We can represent an N-dimensional datapoint by its projections onto the M principal directions • This loses all information about where the data point is located in the remaining orthogonal directions. • We reconstruct by using the mean value (over all the data) on the N-M directions that are not represented. • The reconstruction error is the sum over all these unrepresented directions of the squared differences from the mean.

  31. A picture of PCA with N=2 and M=1 The red point is represented by the green point. Our “reconstruction” of the red point has an error equal to the squared distance between red and green points. First principal component: Direction of greatest variance

  32. If we force the hidden unit whose weight vector is closest to the input vector to have an activity of 1 and the rest to have activities of 0, we get clustering. The weight vector of each hidden unit represents the center of a cluster. Input vectors are reconstructed as the nearest cluster center. Requires global winner takes all function to chose the winner Self-supervised backprop and clustering reconstruction data=(x,y)

  33. Clustering and backpropagation • We need to tie the input->hidden weights to be the same as the hidden->output weights. • The only error-derivative is for the output weights. • This derivative pulls the weight vector of the winning cluster towards the data point. • When the weight vector is at the center of gravity of a cluster, the derivatives all balance out because the center of gravity minimizes squared error.

  34. PCA is powerful because it uses distributed representations but limited because its representations are linearly related to the data Autoencoders with more hidden layers are not limited this way. Clustering is powerful because it uses very non-linear representations but limited because its representations are local (not componential). We need representations that are both distributed and non-linear Unfortunately, these are typically very hard to learn. A spectrum of representations Local Distributed PCA Linear non-linear clustering What we need

  35. Clustering • We assume that the data was generated from a number of different classes. The aim is to cluster data from the same class together. • How do we decide the number of classes? • Why not put each datapoint into a separate class? • What is the payoff for clustering things together? • What if the classes are hierarchical? • What if each data vector can be classified in many different ways? • A one-out-of-N classification is not nearly as informative as a feature vector.

  36. Assume the data lives in a Euclidean space. Assume we want k classes. Assume we start with randomly located cluster centers The algorithm alternates between two steps: Assignment step: Assign each datapoint to the closest cluster. Refitting step: Move each cluster center to the center of gravity of the data assigned to it. The k-means algorithm Assignments Refitted means

  37. Why K-means converges • Whenever an assignment is changed, the sum squared distances of datapoints from their assigned cluster centers is reduced. • Whenever a cluster center is moved the sum squared distances of the datapoints from their currently assigned cluster centers is reduced. • If the assignments do not change in the assignment step, we have converged.

  38. There is nothing to prevent k-means getting stuck at local minima. We could try many random starting points We could try to simultaneously merge two nearby clusters and split a big cluster into two. A bad local optimum Local minima We could use local density information to merge and split clusters

  39. Soft k-means • Instead of making hard assignments of data points to clusters, we can make soft assignments. One cluster may have a responsibility of .7 for a data point and another may have a responsibility of .3 (fuzzy clustering). • Allows a cluster to use more information about the data in the refitting step. • What happens to our convergence guarantee? • How do we decide on the soft assignments?

  40. A generative view of clustering • We need a sensible measure of what it means to cluster the data well. • This makes it possible to judge different methods. • It may make it possible to decide on the number of clusters. • An obvious approach is to imagine that the data was produced by a generative model. • Then we can adjust the parameters of the model to maximize the probability density that it would produce exactly the data we observed.

  41. The mixture of Gaussians generative model • First pick one of the k Gaussians with a probability that is called its “mixing proportion”. • Then generate a random point from the chosen Gaussian. • The probability of generating the exact data we observed is zero, but we can still try to maximize the probability density. • Adjust the means of the Gaussians • Adjust the variances of the Gaussians on each dimension. • Adjust the mixing proportions of the Gaussians.

  42. The mixture of Gaussians generative model • 500 points drawn from the mixture of 3 Gaussians • a) samples from 3 classes (3 colors) • b) the same samples with assigned values of responsibilities

  43. The Expectation-step: Computing responsibilities Prior for Gaussian i Posterior for Gaussian i • In order to adjust the parameters, we must first solve the inference problem: Which Gaussian generated each datapoint? • We cannot be sure, so it’s a distribution over all possibilities. • Use Bayes theorem to get posterior probabilities Bayes theorem Mixing proportion Product over all data dimensions

  44. The Maximization-step: Computing new mixing proportions • Each Gaussian gets a certain amount of posterior probability for each datapoint. • The optimal mixing proportion to use (given these posterior probabilities) is just the fraction of the data that the Gaussian gets responsibility for. Posterior for Gaussian i Data for training case c Number of training cases

  45. More M-step: Computing the new means • We just take the center-of gravity of the data that the Gaussian is responsible for. • Just like in K-means, except the data is weighted by the posterior probability of the Gaussian. • Guaranteed to lie in the convex hull of the data • Could be big initial jump

  46. More M-step: Computing the new variances • We fit the variance of each Gaussian, i, on each dimension, d, to the posterior-weighted data • Its more complicated if we use a full-covariance Gaussian that is not aligned with the axes.

  47. How many Gaussians do we use? • Hold back a validation set. • Try various numbers of Gaussians • Pick the number that gives the highest density to the validation set. • Refinements: • We could make the validation set smaller by using several different validation sets and averaging the performance. • We should use all of the data for a final training of the parameters once we have decided on the best number of Gaussians.

  48. Avoiding local optima • EM can easily get stuck in local optima. • It helps to start with very large Gaussians that are all very similar and to only reduce the variance gradually. • As the variance is reduced, the Gaussians spread out along the first principal component of the data.

  49. Speeding up the fitting • Fitting a mixture of Gaussians is one of the main occupations of an intellectually shallow field called data-mining. • If we have huge amounts of data, speed is very important. Some tricks are: • Initialize the Gaussians using k-means • Makes it easy to get trapped. • Initialize K-means using a subset of the datapoints so that the means lie on the low-dimensional manifold. • Find the Gaussians near a datapoint more efficiently. • Use a K dimensional tree (KD-tree) to quickly eliminate distant Gaussians from consideration. • Fit Gaussians greedily • Steal some mixing proportion from the already fitted Gaussians and use it to fit poorly modeled datapoints better.

  50. The next 5 slides are optional extra material that will not be in the final exam • There are several different ways to show that Expectation- Maximization algorithm (EM) converges. • My favorite method is to show that there is a cost function that is reduced by both the E-step and the M-step. • But the cost function is considerably more complicated than the one for K-Means.

More Related