版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
LinearAlgebraPrimerProfessorFei-FeiLiStanfordVisionLab11-Dec-251Another,veryin-depthlinearalgebrareviewfromCS229isavailablehere:http://AndavideodiscussionoflinearalgebrafromEE263ishere(lectures3and4):http://OutlineVectorsandmatricesBasicMatrixOperationsSpecialMatricesTransformationMatricesHomogeneouscoordinatesTranslationMatrixinverseMatrixrankSingularValueDecomposition(SVD)UseforimagecompressionUseforPrincipalComponentAnalysis(PCA)Computeralgorithm11-Dec-252OutlineVectorsandmatricesBasicMatrixOperationsSpecialMatricesTransformationMatricesHomogeneouscoordinatesTranslationMatrixinverseMatrixrankSingularValueDecomposition(SVD)UseforimagecompressionUseforPrincipalComponentAnalysis(PCA)Computeralgorithm11-Dec-253Vectorsandmatricesarejustcollectionsoforderednumbersthatrepresentsomething:movementsinspace,scalingfactors,pixelbrightnesses,etc.We’lldefinesomecommonusesandstandardoperationsonthem.VectorAcolumnvectorwhereArowvectorwheredenotesthetransposeoperation11-Dec-254VectorWe’lldefaulttocolumnvectorsinthisclassYou’llwanttokeeptrackoftheorientationofyourvectorswhenprogramminginMATLABYoucantransposeavectorVinMATLABbywritingV’.(Butinclassmaterials,wewillalwaysuseVTtoindicatetranspose,andwewilluseV’tomean“Vprime”)11-Dec-255VectorshavetwomainusesVectorscanrepresentanoffsetin2Dor3DspacePointsarejustvectorsfromtheorigin11-Dec-256Data(pixels,gradientsatanimagekeypoint,etc)canalsobetreatedasavectorSuchvectorsdon’thaveageometricinterpretation,butcalculationslike“distance”canstillhavevalueMatrix
11-Dec-257Images11-Dec-258MATLABrepresentsanimageasamatrixofpixelbrightnessesNotethatmatrixcoordinatesareNOTCartesiancoordinates.Theupperleftcorneris[y,x]=(1,1)=ColorImagesGrayscaleimageshaveonenumberperpixel,andarestoredasanm×nmatrix.Colorimageshave3numbersperpixel–red,green,andbluebrightnessesStoredasanm×n×3matrix11-Dec-259=BasicMatrixOperationsWewilldiscuss:AdditionScalingDotproductMultiplicationTransposeInverse/pseudoinverseDeterminant/trace11-Dec-2510MatrixOperationsAdditionCanonlyaddamatrixwithmatchingdimensions,orascalar.Scaling11-Dec-2511MatrixOperationsInnerproduct(dotproduct)ofvectorsMultiplycorrespondingentriesoftwovectorsandadduptheresultx·yisalso|x||y|Cos(theanglebetweenxandy)11-Dec-2512MatrixOperationsInnerproduct(dotproduct)ofvectorsIfBisaunitvector,thenA·BgivesthelengthofAwhichliesinthedirectionofB11-Dec-2513MatrixOperationsMultiplicationTheproductABis:Eachentryintheresultis(thatrowofA)dotproductwith(thatcolumnofB)Manyuses,whichwillbecoveredlater11-Dec-2514MatrixOperationsMultiplicationexample:11-Dec-2515Eachentryofthematrixproductismadebytakingthedotproductofthecorrespondingrowintheleftmatrix,withthecorrespondingcolumnintherightone.MatrixOperationsPowersByconvention,wecanrefertothematrixproductAAasA2,andAAAasA3,etc.Obviouslyonlysquarematricescanbemultipliedthatway11-Dec-2516MatrixOperationsTranspose–flipmatrix,sorow1becomescolumn1Ausefulidentity:11-Dec-2517DeterminantreturnsascalarRepresentsarea(orvolume)oftheparallelogramdescribedbythevectorsintherowsofthematrixFor,Properties:11-Dec-2518MatrixOperationsTraceInvarianttoalotoftransformations,soit’susedsometimesinproofs.(Rarelyinthisclassthough.)Properties:11-Dec-2519MatrixOperationsSpecialMatricesIdentitymatrixISquarematrix,1’salongdiagonal,0’selsewhereI
?
[anothermatrix]=[thatmatrix]DiagonalmatrixSquarematrixwithnumbersalongdiagonal,0’selsewhereAdiagonal?
[anothermatrix]scalestherowsofthatmatrix11-Dec-2520SpecialMatricesSymmetricmatrixSkew-symmetricmatrix11-Dec-2521OutlineVectorsandmatricesBasicMatrixOperationsSpecialMatricesTransformationMatricesHomogeneouscoordinatesTranslationMatrixinverseMatrixrankSingularValueDecomposition(SVD)UseforimagecompressionUseforPrincipalComponentAnalysis(PCA)Computeralgorithm11-Dec-2522Matrixmultiplicationcanbeusedtotransformvectors.Amatrixusedinthiswayiscalledatransformationmatrix.TransformationMatricescanbeusedtotransformvectorsinusefulways,throughmultiplication:x’=AxSimplestisscaling:(Verifytoyourselfthatthematrixmultiplicationworksoutthisway)11-Dec-2523RotationHowcanyouconvertavectorrepresentedinframe“0”toanew,rotatedcoordinateframe“1”?Rememberwhatavectoris:[componentindirectionoftheframe’sxaxis,componentindirectionofyaxis]11-Dec-2524RotationSotorotateitwemustproducethisvector:[componentindirectionofnewxaxis,componentindirectionofnewyaxis]Wecandothiseasilywithdotproducts!Newxcoordinateis[originalvector]dot[thenewxaxis]Newycoordinateis[originalvector]dot[thenewyaxis]11-Dec-2525RotationInsight:thisiswhathappensinamatrix*vectormultiplicationResultxcoordinateis[originalvector]dot
[matrixrow1]Somatrixmultiplicationcanrotateavectorp:11-Dec-2526RotationSupposeweexpressapointinacoordinatesystemwhichisrotatedleftIfweusetheresultinthesamecoordinatesystem,wehaverotatedthepointright11-Dec-2527Thus,rotationmatricescanbeusedtorotatevectors.We’llusuallythinkoftheminthatsense--asoperatorstorotatevectors2DRotationMatrixFormulaCounter-clockwiserotationbyanangle
Pxy’P’
x’y11-Dec-2528TransformationMatricesMultipletransformationmatricescanbeusedtotransformapoint:
p’=R2R1SpTheeffectofthisistoapplytheirtransformationsoneaftertheother,fromrighttoleft.Intheexampleabove,theresultis
(R2(R1(Sp)))Theresultisexactlythesameifwemultiplythematricesfirst,toformasingletransformationmatrix:
p’=(R2R1S)p11-Dec-2529HomogeneoussystemIngeneral,amatrixmultiplicationletsuslinearlycombinecomponentsofavectorThisissufficientforscale,rotate,skewtransformations.Butnotice,wecan’taddaconstant!
11-Dec-2530HomogeneoussystemThe(somewhathacky)solution?Sticka“1”attheendofeveryvector:Nowwecanrotate,scale,andskewlikebefore,ANDtranslate(notehowthemultiplicationworksout,above)Thisiscalled“homogeneouscoordinates”11-Dec-2531HomogeneoussystemInhomogeneouscoordinates,themultiplicationworksoutsotherightmostcolumnofthematrixisavectorthatgetsadded.Generally,ahomogeneoustransformationmatrixwillhaveabottomrowof[001],sothattheresulthasa“1”atthebottomtoo.11-Dec-2532HomogeneoussystemOnemorethingwemightwant:todividetheresultbysomethingForexample,wemaywanttodividebyacoordinate,tomakethingsscaledownastheygetfartherawayinacameraimageMatrixmultiplicationcan’tactuallydivideSo,byconvention,inhomogeneouscoordinates,we’lldividetheresultbyitslastcoordinateafterdoingamatrixmultiplication11-Dec-25332DTranslationtPP’11-Dec-253411-Dec-25352DTranslationusingHomogeneousCoordinatesPxytxtyP’ttPScalingPP’11-Dec-2536ScalingEquationPxysxxP’sy
y11-Dec-2537PP’=S?PP’’=T?P’P’’=T?P’=T?(S?P)=T?S?P=A?
PScaling&TranslatingP’’11-Dec-2538Scaling&TranslatingA11-Dec-2539Translating&Scaling
!=Scaling&Translating11-Dec-2540RotationPP’11-Dec-2541RotationEquationsCounter-clockwiserotationbyanangle
Pxy’P’
x’y11-Dec-2542RotationMatrixPropertiesTransposeofarotationmatrixproducesarotationintheoppositedirectionTherowsofarotationmatrixarealwaysmutuallyperpendicular(a.k.a.orthogonal)unitvectors(andsoareitscolumns)11-Dec-2543PropertiesA2Drotationmatrixis2x2Note:Rbelongstothecategoryofnormalmatricesandsatisfiesmanyinterestingproperties:11-Dec-2544Rotation+Scaling+TranslationP’=(TRS)P11-Dec-2545Thisistheformofthegeneral-purposetransformationmatrixOutlineVectorsandmatricesBasicMatrixOperationsSpecialMatricesTransformationMatricesHomogeneouscoordinatesTranslationMatrixinverseMatrixrankSingularValueDecomposition(SVD)UseforimagecompressionUseforPrincipalComponentAnalysis(PCA)Computeralgorithm11-Dec-2546TheinverseofatransformationmatrixreversesitseffectGivenamatrixA,itsinverseA-1
isamatrixsuchthatAA-1=A-1A=IE.g.Inversedoesnotalwaysexist.IfA-1exists,Aisinvertibleornon-singular.Otherwise,it’ssingular.Usefulidentities,formatricesthatareinvertible:11-Dec-2547InversePseudoinverseSayyouhavethematrixequationAX=B,whereAandBareknown,andyouwanttosolveforXYoucoulduseMATLABtocalculatetheinverseandpremultiplybyit:A-1AX=A-1B→X=A-1BMATLABcommandwouldbeinv(A)*BButcalculatingtheinverseforlargematricesoftenbringsproblemswithcomputerfloating-pointresolution(becauseitinvolvesworkingwithverysmallandverylargenumberstogether).Or,yourmatrixmightnotevenhaveaninverse.11-Dec-2548MatrixOperationsPseudoinverseFortunately,thereareworkaroundstosolveAX=Binthesesituations.AndMATLABcandothem!Insteadoftakinganinverse,directlyaskMATLABtosolveforXinAX=B,bytypingA\BMATLABwilltryseveralappropriatenumericalmethods(includingthepseudoinverseiftheinversedoesn’texist)MATLABwillreturnthevalueofXwhichsolvestheequationIfthereisnoexactsolution,itwillreturntheclosestoneIftherearemanysolutions,itwillreturnthesmallestone11-Dec-2549MatrixOperationsMATLABexample:11-Dec-2550MatrixOperations>>x=A\Bx=1.0000-0.5000OutlineVectorsandmatricesBasicMatrixOperationsSpecialMatricesTransformationMatricesHomogeneouscoordinatesTranslationMatrixinverseMatrixrankSingularValueDecomposition(SVD)UseforimagecompressionUseforPrincipalComponentAnalysis(PCA)Computeralgorithm11-Dec-2551Therankofatransformationmatrixtellsyouhowmanydimensionsittransformsavectorto.LinearindependenceSupposewehaveasetofvectorsv1,…,vnIfwecanexpressv1asalinearcombinationoftheothervectorsv2…vn,thenv1islinearlydependentontheothervectors.Thedirectionv1canbeexpressedasacombinationofthedirectionsv2…vn.(E.g.v1=.7
v2-.7
v4)Ifnovectorislinearlydependentontherestoftheset,thesetislinearlyindependent.Commoncase:asetofvectorsv1,…,vnisalwayslinearlyindependentifeachvectorisperpendiculartoeveryothervector(andnon-zero)11-Dec-2552LinearindependenceNotlinearlyindependent11-Dec-2553LinearlyindependentsetMatrixrankColumn/rowrankColumnrankalwaysequalsrowrankMatrixrank11-Dec-2554MatrixrankFortransformationmatrices,theranktellsyouthedimensionsoftheoutputE.g.ifrankofAis1,thenthetransformation
p’=Ap
mapspointsontoaline.Here’samatrixwithrank1:11-Dec-2555Allpointsgetmappedtotheliney=2xMatrixrankIfanmxmmatrixisrankm,wesayit’s“fullrank”Mapsanmx1vectoruniquelytoanothermx1vectorAninversematrixcanbefoundIfrank<m,wesayit’s“singular”Atleastonedimensionisgettingcollapsed.NowaytolookattheresultandtellwhattheinputwasInversedoesnotexistInversealsodoesn’texistfornon-squarematrices11-Dec-2556OutlineVectorsandmatricesBasicMatrixOperationsSpecialMatricesTransformationMatricesHomogeneouscoordinatesTranslationMatrixinverseMatrixrankSingularValueDecomposition(SVD)UseforimagecompressionUseforPrincipalComponentAnalysis(PCA)Computeralgorithm11-Dec-2557SVDisanalgorithmthatrepresentsanymatrixastheproductof3matrices.Itisusedtodiscoverinterestingstructureinamatrix.SingularValueDecomposition(SVD)Thereareseveralcomputeralgorithmsthatcan“factor”amatrix,representingitastheproductofsomeothermatricesThemostusefuloftheseistheSingularValueDecomposition.RepresentsanymatrixAasaproductofthreematrices:UΣVTMATLABcommand:[U,S,V]=svd(A)11-Dec-2558SingularValueDecomposition(SVD)
UΣVT=AWhereUandVarerotationmatrices,andΣisascalingmatrix.Forexample:11-Dec-2559SingularValueDecomposition(SVD)Beyond2D:Ingeneral,ifAismxn,thenUwillbemxm,Σwillbemxn,andVTwillbenxn.(Notethedimensionsworkouttoproducemxnaftermultiplication)11-Dec-2560SingularValueDecomposition(SVD)UandVarealwaysrotationmatrices.Geometricrotationmaynotbeanapplicableconcept,dependingonthematrix.Sowecallthem“unitary”matrices–eachcolumnisaunitvector.ΣisadiagonalmatrixThenumberofnonzeroentries=rankofAThealgorithmalwayssortstheentrieshightolow11-Dec-2561SVD
ApplicationsWe’vediscussedSVDintermsofgeometrictransformationmatricesButSVDofanimagematrixcanalsobeveryusefulTounderstandthis,we’lllookatalessgeometricinterpretationofwhatSVDisdoing11-Dec-2562SVD
ApplicationsLookathowthemultiplicationworksout,lefttoright:Column1ofUgetsscaledbythefirstvaluefromΣ.Theresultingvectorgetsscaledbyrow1ofVTtoproduceacontributiontothecolumnsofA11-Dec-2563SVD
ApplicationsEachproductof(columniofU)?(valueifromΣ)?(rowiofVT)producesacomponentofthefinalA.11-Dec-2564+=SVD
ApplicationsWe’rebuildingAasalinearcombinationofthecolumnsof
UUsingallcolumnsofU,we’llrebuildtheoriginalmatrixperfectlyBut,inreal-worlddata,oftenwecanjustusethefirstfewcolumnsofUandwe’llgetsomethingclose(e.g.thefirstApartial,above)11-Dec-2565SVD
ApplicationsWecancallthosefirstfewcolumnsof
UthePrincipalComponentsofthedataTheyshowthemajorpatternsthatcanbeaddedtoproducethecolumnsoftheoriginalmatrixTherowsofVTshowhowtheprincipalcomponentsaremixedtoproducethecolumnsofthematrix11-Dec-2566SVD
ApplicationsWecanlookatΣtoseethatthefirstcolumnhasalargeeffect11-Dec-2567whilethesecondcolumnhasamuchsmallereffectinthisexampleSVD
Applications11-Dec-2568Forthisimage,usingonlythefirst10of300principalcomponentsproducesarecognizablereconstructionSo,SVDcanbeusedforimagecompressionPrincipalComponentAnalysisRemember,columnsof
UarethePrincipalComponentsofthedata:themajorpatternsthatcanbeaddedtoproducethecolumnsoftheoriginalmatrixOneuseofthisistoconstructamatrixwhereeachcolumnisaseparatedatasampleRunSVDonthatmatrix,andlookatthefirstfewcolumnsofUtoseepatternsthatarecommonamongthecolumnsThisiscalledPrincipalComponentAnalysis(orPCA)ofthedatasamples11-Dec-2569PrincipalComponentAnalysisOften,rawdatasampleshavealotofredundancyandpatternsPCAcanallowyoutorepresentdatasamplesasweightsontheprincipalcomponents,ratherthanusingtheoriginalrawformofthedataByrepresentingeachsampleasjustthoseweights,youcanrepresentjustthe“meat”ofwhat’sdifferentbetweensamples.Thisminimalrepresentationmakesmachinelearningandotheralgorithmsmuchmoreefficient11-Dec-2570OutlineVectorsandmatricesBasicMatrixOperationsSpecialMatricesTransformationMatricesHomogeneouscoordinatesTranslationMatrixinverseMatrixrankSingularValueDecomposition(SVD)UseforimagecompressionUseforPrincipalComponentAnalysis(PCA)Computeralgorithm11-Dec-2571ComputerscancomputeSVDveryquickly.We’llbrieflydiscussthealgorithm,forthosewhoareinterested.Addendum:HowisSVDcomputed?Forthisclass:tellMATLABtodoit.Usether
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 吉安市文化傳媒集團(tuán)有限責(zé)任公司2025年公開招聘勞務(wù)派遣工作人員備考核心試題附答案解析
- 店鋪欠款合同范本
- 質(zhì)量監(jiān)督協(xié)議書
- 詐騙協(xié)議書范本
- 學(xué)生傷賠協(xié)議書
- 裝修索賠協(xié)議書
- 小型工程協(xié)議書
- 武漢某國企市場拓展專員招聘考試核心試題及答案解析
- 裝潢委托協(xié)議書
- 資詢合同解除協(xié)議
- 西南名校聯(lián)盟2026屆高三12月“3+3+3”高考備考診斷性聯(lián)考(一)英語試卷(含答案詳解)
- 黃埔區(qū)2025年第二次招聘社區(qū)專職工作人員備考題庫有答案詳解
- 2025貴州錦麟化工有限責(zé)任公司第三次招聘7人備考筆試題庫及答案解析
- 2025廣東廣州琶洲街道招聘雇員(協(xié)管員)5人筆試考試參考試題及答案解析
- 2025-2030中國考試系統(tǒng)行業(yè)市場發(fā)展現(xiàn)狀分析及發(fā)展趨勢與投資前景研究報(bào)告
- 2024年第一次廣東省普通高中數(shù)學(xué)學(xué)業(yè)水平合格性考試真題卷含答案
- 2025年中醫(yī)健康管理服務(wù)合同模板
- 《紅軍重走長征路》課件
- 機(jī)械加工工藝過程卡片
- 2企業(yè)安全生產(chǎn)標(biāo)準(zhǔn)化建設(shè)咨詢服務(wù)方案
- 腰椎骨折課件教學(xué)課件
評(píng)論
0/150
提交評(píng)論