├── .gitmodules ├── README.org ├── application.conf ├── project └── Build.scala ├── src └── main │ ├── moro │ ├── 000_index.json │ ├── 00_intro.json │ ├── 01_motiv.json │ ├── 02_vanilla.json │ ├── 03_nmf.json │ ├── 04_binarymf.json │ ├── 05_knowledge.json │ ├── 06_tf.json │ ├── 07_cmf.json │ ├── 08_prediction.json │ ├── 09_convex.json │ ├── 10_summary.json │ ├── SGD_converges_to_SVD.json │ ├── biblio.json │ ├── figures │ │ ├── .DS_Store │ │ ├── 00 │ │ │ ├── .DS_Store │ │ │ ├── mf_intro.png │ │ │ ├── mfw1.png │ │ │ ├── mfw2.png │ │ │ ├── mfw3.png │ │ │ ├── s1f1.png │ │ │ └── s1f2.png │ │ ├── 04 │ │ │ ├── i20.png │ │ │ ├── i200.png │ │ │ ├── identity-geom.png │ │ │ ├── identity-geom.pptx │ │ │ ├── identity200x200.pdf │ │ │ ├── identity20x20.pdf │ │ │ ├── identity60x60.pdf │ │ │ ├── sequence-pred-logit.png │ │ │ ├── sequence-pred-squared.png │ │ │ ├── sequence-train.png │ │ │ ├── transitivityGroup10pct-logistic.png │ │ │ ├── transitivityGroup10pct-squared.png │ │ │ └── transitivityGroup10pct-training.png │ │ ├── 06 │ │ │ ├── cmf_databases.png │ │ │ ├── faces.png │ │ │ ├── faces_expt.png │ │ │ ├── gene_expression.png │ │ │ └── relational_database_health.png │ │ ├── 07 │ │ │ ├── Backprop.png │ │ │ ├── Baselines-0.png │ │ │ ├── Baselines-1.png │ │ │ ├── Baselines-10.png │ │ │ ├── Baselines-11.png │ │ │ ├── Baselines-12.png │ │ │ ├── Baselines-13.png │ │ │ ├── Baselines-14.png │ │ │ ├── Baselines-15.png │ │ │ ├── Baselines-2.png │ │ │ ├── Baselines-3.png │ │ │ ├── Baselines-4.png │ │ │ ├── Baselines-5.png │ │ │ ├── Baselines-6.png │ │ │ ├── Baselines-7.png │ │ │ ├── Baselines-8.png │ │ │ ├── Baselines-9.png │ │ │ ├── MF-0.png │ │ │ ├── MF-1.png │ │ │ ├── MF-10.png │ │ │ ├── MF-11.png │ │ │ ├── MF-12.png │ │ │ ├── MF-13.png │ │ │ ├── MF-14.png │ │ │ ├── MF-15.png │ │ │ ├── MF-16.png │ │ │ ├── MF-2.png │ │ │ ├── MF-3.png │ │ │ ├── MF-4.png │ │ │ ├── MF-5.png │ │ │ ├── MF-6.png │ │ │ ├── MF-7.png │ │ │ ├── MF-8.png │ │ │ ├── MF-9.png │ │ │ ├── Overview-0.png │ │ │ ├── Overview-1.png │ │ │ ├── Overview-2.png │ │ │ ├── Overview-3.png │ │ │ ├── Overview-4.png │ │ │ ├── Overview-5.png │ │ │ ├── Overview-6.png │ │ │ ├── Overview-7.png │ │ │ ├── flikr.png │ │ │ ├── results.png │ │ │ ├── subsample-wMAP.png │ │ │ ├── zero-shot-1.png │ │ │ ├── zero-shot-2.png │ │ │ ├── zero-shot-3.png │ │ │ ├── zero-shot-4.png │ │ │ └── zero-shot-5.png │ │ ├── 08 │ │ │ ├── multitask.png │ │ │ ├── parse_results.png │ │ │ ├── s8s1.png │ │ │ ├── s8s10.png │ │ │ ├── s8s11.png │ │ │ ├── s8s2.png │ │ │ ├── s8s3.png │ │ │ ├── s8s4.png │ │ │ ├── s8s5.png │ │ │ ├── s8s6.png │ │ │ ├── s8s7.png │ │ │ ├── s8s8.png │ │ │ ├── s8s9.png │ │ │ └── srl-results.png │ │ ├── 09 │ │ │ ├── hankel_grammar.png │ │ │ └── make_hankel.png │ │ ├── 4drubik.png │ │ ├── IntroToLDA.png │ │ ├── KBP_MF_application.png │ │ ├── SVD.png │ │ ├── SVDtrunc.png │ │ ├── ai │ │ │ ├── SVD.ai │ │ │ ├── SVD1.ai │ │ │ ├── SVD2.ai │ │ │ ├── fb_dm.ai │ │ │ ├── m-mult.ai │ │ │ ├── mf.ai │ │ │ ├── mf_apps.ai │ │ │ ├── nonSVD.ai │ │ │ └── norm3.ai │ │ ├── constrainedmf.png │ │ ├── fibers.png │ │ ├── homer.jpg │ │ ├── identity.png │ │ ├── mf-neural.png │ │ ├── mfprior.png │ │ ├── nickel.png │ │ ├── norm1of4.png │ │ ├── norm2of4.png │ │ ├── norm3of4.png │ │ ├── norm4of4.png │ │ ├── norms.png │ │ ├── omni │ │ │ ├── .DS_Store │ │ │ ├── mf-neural.gstencil │ │ │ │ ├── data.plist │ │ │ │ ├── image10.pdf │ │ │ │ ├── image13.pdf │ │ │ │ ├── image15.pdf │ │ │ │ ├── image2.pdf │ │ │ │ ├── image3.pdf │ │ │ │ ├── image7.pdf │ │ │ │ ├── image8.pdf │ │ │ │ └── image9.pdf │ │ │ ├── rescal-neural.gstencil │ │ │ │ ├── data.plist │ │ │ │ ├── image10.pdf │ │ │ │ ├── image13.pdf │ │ │ │ ├── image14.pdf │ │ │ │ ├── image17.pdf │ │ │ │ ├── image18.pdf │ │ │ │ ├── image19.pdf │ │ │ │ ├── image2.pdf │ │ │ │ └── image8.pdf │ │ │ ├── tf-mat.gstencil │ │ │ │ ├── data.plist │ │ │ │ ├── image16.pdf │ │ │ │ └── image17.pdf │ │ │ ├── tf-matz.gstencil │ │ │ │ ├── data.plist │ │ │ │ └── image17.pdf │ │ │ ├── tf-rank.gstencil │ │ │ │ ├── data.plist │ │ │ │ └── image17.pdf │ │ │ └── tf-vec.gstencil │ │ │ │ ├── data.plist │ │ │ │ ├── image16.pdf │ │ │ │ └── image17.pdf │ │ ├── readTheMatrix.png │ │ ├── rescal-neural.png │ │ ├── rescal-results.png │ │ ├── rescal.png │ │ ├── slices.png │ │ ├── tensor-ex.png │ │ ├── tf-mat.png │ │ ├── tf-matz.png │ │ ├── tf-rank.png │ │ ├── tf-vec.png │ │ ├── tfmf.png │ │ ├── tucker1.png │ │ ├── tucker2.png │ │ ├── tucker3.png │ │ ├── uschema-results.png │ │ ├── van.png │ │ └── vanillaMF.png │ ├── interactive.json │ ├── overview.json │ └── test.json │ └── scala │ └── uk │ └── ac │ └── ucl │ └── cs │ └── mr │ └── acltutorial │ ├── BinaryMF.scala │ ├── ManualCMF.scala │ ├── ManualMF.scala │ ├── MatrixRenderer.scala │ └── Renderer.scala ├── tutorial.pdf └── tutorial_2up.pdf /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "moro"] 2 | path = moro 3 | url = https://github.com/wolfe-pack/moro.git 4 | [submodule "wolfe"] 5 | path = wolfe 6 | url = https://github.com/wolfe-pack/wolfe.git 7 | branch = dev 8 | [submodule "htmlgen"] 9 | path = htmlgen 10 | url = https://github.com/sameersingh/htmlgen.git 11 | -------------------------------------------------------------------------------- /README.org: -------------------------------------------------------------------------------- 1 | ** ACL 2015 Tutorial 2 | *** Cloning 3 | #+BEGIN_SRC sh 4 | git clone https://github.com/uclmr/acl2015tutorial.git 5 | cd acl2015tutorial 6 | git submodule update --init --recursive 7 | cd wolfe; git pull; sbt publish-local; cd .. 8 | cd htmlgen; git pull; mvn clean install -Dgpg.skip=true; cd .. 9 | cd moro; git checkout master; git pull; cd .. 10 | cp application.conf moro/conf 11 | cd moro/public/ 12 | ln -s ../../src/main/moro/figures 13 | cd ../.. 14 | sbt compile 15 | #+END_SRC 16 | *** Running Moro notebook 17 | #+BEGIN_SRC sh 18 | cd moro; sbt run 19 | #+END_SRC 20 | Then go to =localhost:9000= in your browser. 21 | *** Opening slides 22 | Got to =http://localhost:9000/doc/present/overview= in your browser. Replace =overview= with the name of your slides. 23 | *** Committing your slides 24 | #+BEGIN_SRC 25 | cd .. 26 | git add src/main/moro/*.json 27 | git commit -am "Added slide" 28 | git push 29 | #+END_SRC 30 | -------------------------------------------------------------------------------- /application.conf: -------------------------------------------------------------------------------- 1 | moro { 2 | # document root 3 | docRoot = "../src/main/moro/" 4 | views.editor.hideAfterCompile = false 5 | compilers { 6 | scala { 7 | plugins = ["/Users/rockt/.ivy2/cache/org.scalamacros/paradise_2.11.4/jars/paradise_2.11.4-2.1.0-M1.jar"] 8 | aceTheme = "chaos" 9 | imports = [ 10 | "org.sameersingh.htmlgen.D3jsConverter.Implicits._", 11 | "org.sameersingh.scalaplot.Implicits._", 12 | "org.sameersingh.htmlgen.Custom._", 13 | "org.sameersingh.htmlgen._", 14 | "ml.wolfe._", 15 | "ml.wolfe.Wolfe._", 16 | "ml.wolfe.macros.OptimizedOperators._", 17 | "ml.wolfe.D3Implicits._", 18 | "ml.wolfe.util.Multidimensional._", 19 | "ml.wolfe.nlp._", 20 | "ml.wolfe.ui._", 21 | "ml.wolfe.term.TermImplicits._", 22 | "ml.wolfe.term._", 23 | "ml.wolfe.term.Argmaxer._" 24 | ] 25 | classPath = [ 26 | "../adi/target/scala-2.11/classes", 27 | "../stat-nlp-book/target/scala-2.11/classes", 28 | "../target/scala-2.11/classes", 29 | "/Users/rockt/workspace/wolfe/wolfe-nlp/target/scala-2.11/classes", 30 | "/Users/rockt/workspace/wolfe/wolfe-core/target/scala-2.11/classes" 31 | ] 32 | classesForJarPath = [ 33 | "breeze.linalg.DenseVector", 34 | "breeze.macros.expand", 35 | "org.slf4j.Logger", 36 | "com.typesafe.scalalogging.slf4j.Logger", 37 | "scala.reflect.macros.Aliases", 38 | "ml.wolfe.term.Term", 39 | "ml.wolfe.util.Util", 40 | //"ml.wolfe.nlp.Token", 41 | "ml.wolfe.examples.DocClassifyExample" 42 | "ml.wolfe.ui.BratRenderer", 43 | //"ml.wolfe.macros.Library", 44 | "cc.factorie.model.Model", 45 | "org.sameersingh.htmlgen.Converter", 46 | "org.sameersingh.scalaplot.Implicits", 47 | "ml.wolfe.nlp.converters.SISTAProcessors", 48 | "edu.arizona.sista.processors.corenlp.CoreNLPProcessor", 49 | "com.typesafe.scalalogging.Logging", 50 | "com.typesafe.scalalogging.slf4j.LazyLogging", 51 | "com.typesafe.config.Config" 52 | ] 53 | aggregate: true 54 | } 55 | } 56 | } -------------------------------------------------------------------------------- /project/Build.scala: -------------------------------------------------------------------------------- 1 | import sbt._ 2 | import sbt.Keys._ 3 | 4 | object BuildSettings { 5 | val buildName = "acltutorial" 6 | val buildOrganization = "uk.ac.ucl.cs.mr" 7 | val buildScalaVersion = "2.11.4" 8 | 9 | val buildSettings = Defaults.defaultSettings ++ Seq( 10 | organization := buildOrganization, 11 | scalaVersion := buildScalaVersion, 12 | scalacOptions := Seq("-unchecked", "-deprecation", "-feature"), //, "-Yrangepos"? 13 | libraryDependencies ++= Seq( 14 | "org.sameersingh.scalaplot" % "scalaplot" % "0.1", 15 | "com.google.guava" % "guava" % "18.0", 16 | "org.scala-lang.modules" %% "scala-pickling" % "0.10.0"), 17 | 18 | resolvers ++= Seq( 19 | "IESL Release" at "https://dev-iesl.cs.umass.edu/nexus/content/groups/public", 20 | Resolver.mavenLocal, 21 | Resolver.defaultLocal, 22 | Resolver.sonatypeRepo("snapshots"), 23 | Resolver.sonatypeRepo("releases"), 24 | "UIUC Releases" at "http://cogcomp.cs.illinois.edu/m2repo" 25 | ), 26 | 27 | //shellPrompt := ShellPrompt.buildShellPrompt, 28 | fork in run := true, //use a fresh JVM for sbt run 29 | connectInput in run := true, //to use readLine after sbt run 30 | commands ++= Seq(vmargs), 31 | addCompilerPlugin("org.scalamacros" % "paradise" % "2.1.0-M1" cross CrossVersion.full) 32 | ) 33 | 34 | val generalSettings = 35 | Seq( 36 | initialCommands := """ 37 | import ml.wolfe.Wolfe._ 38 | import ml.wolfe.macros.OptimizedOperators._ 39 | """ 40 | ) 41 | 42 | def vmargs = Command.args("vmargs", "") { 43 | (state, args) => 44 | val javaRunOptions = args.mkString(" ") 45 | println("Applying JVM arguments: " + javaRunOptions) 46 | Project.extract(state).append(javaOptions := Seq(javaRunOptions), state) 47 | } 48 | } 49 | 50 | object Build extends Build { 51 | 52 | import BuildSettings._ 53 | 54 | lazy val wolfeNLP = ProjectRef(file("./wolfe"), "wolfe-nlp") 55 | lazy val wolfeCore = ProjectRef(file("./wolfe"), "wolfe-core") 56 | lazy val wolfeUI = ProjectRef(file("./wolfe"), "wolfe-ui") 57 | lazy val wolfeExamples= ProjectRef(file("./wolfe"), "wolfe-examples") 58 | 59 | lazy val acltutorial = Project( 60 | id = "acltutorial", 61 | base = file("."), 62 | settings = buildSettings 63 | ) dependsOn( 64 | wolfeNLP % "test->test;compile->compile", 65 | wolfeUI % "test->test;compile->compile", 66 | wolfeCore % "test->test;compile->compile", 67 | wolfeExamples % "test->test;compile->compile" 68 | 69 | ) 70 | } 71 | -------------------------------------------------------------------------------- /src/main/moro/000_index.json: -------------------------------------------------------------------------------- 1 | { 2 | "name" : "Index", 3 | "cells" : [ { 4 | "id" : 0, 5 | "compiler" : "markdown", 6 | "input" : { 7 | "sessionId" : null, 8 | "code" : "0. [Introduction](../present/00_intro?controls=false&slideNumber=true&autoSlide=0&loop=false/#/0)\n1. [Seeing the Matrix](../present/01_motiv?controls=false&slideNumber=true&autoSlide=0&loop=false/#/0)\n2. [Vanilla Matrix Factorization](../present/02_vanilla?controls=false&slideNumber=true&autoSlide=0&loop=false/#/0)\n3. [Non-Negative Matrix Factorization](../present/03_nmf?controls=false&slideNumber=true&autoSlide=0&loop=false/#/0)\n4. [Binary Matrx Factorization](../present/04_binarymf?controls=false&slideNumber=true&autoSlide=0&loop=false&transition=none/#/0)\n5. [Inclusion of Prior Knowledge in Factorization Models](../present/05_knowledge?controls=false&slideNumber=true&autoSlide=0&loop=false&transition=none/#/0)\n6. [Tensor Factorization](../present/06_tf?controls=false&slideNumber=true&autoSlide=0&loop=false&transition=concave/#/0)\n7. [Collective Matrix Factorization](../present/07_cmf?controls=false&slideNumber=true&autoSlide=0&loop=false/#/0)\n8. [Discriminative Factorial Models](../present/08_prediction?controls=false&slideNumber=true&autoSlide=0&loop=false/#/0)\n9. [Convexification](../present/09_convex?controls=false&slideNumber=true&autoSlide=0&loop=false/#/0)\n10. [Summary](../present/10_summary?controls=false&slideNumber=true&autoSlide=0&loop=false/#/0)\n11. [Annotated Bibliography](../present/biblio?controls=false&slideNumber=true&autoSlide=0&loop=false/#/0)\n", 9 | "extraFields" : { } 10 | } 11 | } ], 12 | "config" : { } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/moro/00_intro.json: -------------------------------------------------------------------------------- 1 | { 2 | "name" : "Matrix and Tensor Factorization Methods for Natural Language Processing", 3 | "cells" : [ { 4 | "id" : 0, 5 | "compiler" : "markdown", 6 | "input" : { 7 | "sessionId" : null, 8 | "code" : "
\n\n**Guillaume Bouchard,  Jason Naradowsky,  Sebastian Riedel,**\n\n**Tim Rocktäschel,  Andreas Vlachos**\n\n
\n\n*Computer Science Department*\n\n*University College London*", 9 | "extraFields" : { } 10 | } 11 | }, { 12 | "id" : 1, 13 | "compiler" : "section", 14 | "input" : { 15 | "sessionId" : null, 16 | "code" : "mfintro1", 17 | "extraFields" : { } 18 | } 19 | }, { 20 | "id" : 2, 21 | "compiler" : "markdown", 22 | "input" : { 23 | "sessionId" : null, 24 | "code" : "###Matrix Factorization in a Nutshell\n\n", 25 | "extraFields" : { } 26 | } 27 | }, { 28 | "id" : 3, 29 | "compiler" : "section", 30 | "input" : { 31 | "sessionId" : null, 32 | "code" : "mfw1", 33 | "extraFields" : { 34 | "reveal_params" : "data-background=\"../../assets/figures/00/mfw1.png\"" 35 | } 36 | } 37 | }, { 38 | "id" : 4, 39 | "compiler" : "markdown", 40 | "input" : { 41 | "sessionId" : null, 42 | "code" : "", 43 | "extraFields" : { } 44 | } 45 | }, { 46 | "id" : 5, 47 | "compiler" : "section", 48 | "input" : { 49 | "sessionId" : null, 50 | "code" : "mfw2", 51 | "extraFields" : { 52 | "reveal_params" : "data-background=\"../../assets/figures/00/mfw2.png\"" 53 | } 54 | } 55 | }, { 56 | "id" : 6, 57 | "compiler" : "markdown", 58 | "input" : { 59 | "sessionId" : null, 60 | "code" : "", 61 | "extraFields" : { } 62 | } 63 | }, { 64 | "id" : 7, 65 | "compiler" : "section", 66 | "input" : { 67 | "sessionId" : null, 68 | "code" : "mfw3", 69 | "extraFields" : { 70 | "reveal_params" : "data-background=\"../../assets/figures/00/mfw3.png\"" 71 | } 72 | } 73 | }, { 74 | "id" : 8, 75 | "compiler" : "markdown", 76 | "input" : { 77 | "sessionId" : null, 78 | "code" : "", 79 | "extraFields" : { } 80 | } 81 | }, { 82 | "id" : 11, 83 | "compiler" : "section", 84 | "input" : { 85 | "sessionId" : null, 86 | "code" : "intro2", 87 | "extraFields" : { } 88 | } 89 | }, { 90 | "id" : 12, 91 | "compiler" : "markdown", 92 | "input" : { 93 | "sessionId" : null, 94 | "code" : "### NLP and Matrix Factorization\n\n**We already use it!**\n\n- topic modelling: probabilistic LSA, LDA...\n- word embedding learning: word2vec, GLOVE...\n- knowledge base population\n\n **Factorization can improve structured prediction models**:\n\n- Smoothing of model parameters \n\n **Matrix factorization supports logical reasoning:** \n\n- Recent work unites factorization and first-order logic rules", 95 | "extraFields" : { } 96 | } 97 | }, { 98 | "id" : 13, 99 | "compiler" : "section", 100 | "input" : { 101 | "sessionId" : null, 102 | "code" : "Blah", 103 | "extraFields" : { } 104 | } 105 | }, { 106 | "id" : 14, 107 | "compiler" : "markdown", 108 | "input" : { 109 | "sessionId" : null, 110 | "code" : "### Motivation\n\n**Matrix and tensor factorization**\n\n- encompass a variety of learning problems \n\n- well-studied in ML/stats literature\n\n- state-of-the-art performance in many tasks\n", 111 | "extraFields" : { } 112 | } 113 | }, { 114 | "id" : 15, 115 | "compiler" : "section", 116 | "input" : { 117 | "sessionId" : null, 118 | "code" : "Part1", 119 | "extraFields" : { 120 | "reveal_params" : "text-align: left" 121 | } 122 | } 123 | }, { 124 | "id" : 16, 125 | "compiler" : "markdown", 126 | "input" : { 127 | "sessionId" : null, 128 | "code" : "### This tutorial\n
\n**Part 1**\n
\n\n- Seeing the matrix\n\n- Matrix factorization basics\n\n- Non-negative matrix factorization\n\n- Binary matrix factorization\n\n- Inclusion of prior knowledge\n \n\n", 129 | "extraFields" : { } 130 | } 131 | }, { 132 | "id" : 17, 133 | "compiler" : "section", 134 | "input" : { 135 | "sessionId" : null, 136 | "code" : "Part2", 137 | "extraFields" : { 138 | "hide_output" : "false" 139 | } 140 | } 141 | }, { 142 | "id" : 18, 143 | "compiler" : "markdown", 144 | "input" : { 145 | "sessionId" : null, 146 | "code" : "### This tutorial\n
\n**Part 2**\n
\n\n- Tensor factorization basics\n\n- Factorization with a predictive model\n\n- Collective matrix factorization\n\n- Convexification\n", 147 | "extraFields" : { } 148 | } 149 | }, { 150 | "id" : 19, 151 | "compiler" : "section", 152 | "input" : { 153 | "sessionId" : null, 154 | "code" : "outcome", 155 | "extraFields" : { } 156 | } 157 | }, { 158 | "id" : 20, 159 | "compiler" : "markdown", 160 | "input" : { 161 | "sessionId" : null, 162 | "code" : "### Outcomes\n
\n\n- Recognizing potential applications\n\n- Understanding of the mathematical concepts\n\n- Clarification of the connections among models\n\n- Familiarization with existing NLP applications\n", 163 | "extraFields" : { } 164 | } 165 | } ], 166 | "config" : { } 167 | } 168 | -------------------------------------------------------------------------------- /src/main/moro/01_motiv.json: -------------------------------------------------------------------------------- 1 | { 2 | "name" : "Seeing the Matrix", 3 | "cells" : [ { 4 | "id" : 0, 5 | "compiler" : "section", 6 | "input" : { 7 | "sessionId" : null, 8 | "code" : "binary", 9 | "extraFields" : { } 10 | } 11 | }, { 12 | "id" : 1, 13 | "compiler" : "markdown", 14 | "input" : { 15 | "sessionId" : null, 16 | "code" : "### Binary Classification", 17 | "extraFields" : { } 18 | } 19 | }, { 20 | "id" : 2, 21 | "compiler" : "scala", 22 | "input" : { 23 | "sessionId" : null, 24 | "code" : "import uk.ac.ucl.cs.mr.acltutorial._\nimport MatrixRenderer._\n\nval layout = Layout(colHeaderSize=60, ch=45, cw=150, rowHeaderSize=100, numCols=2,numRows=7)\n\nval m1 = Matrix(Seq(Cell(0,0,\"label\"),Cell(0,1,\"features\"),Cell(1,0,1),Cell(1,1,\"f1, f3, f4, f6\"),Cell(2,0,1),Cell(2,1,\"f3, f6\"),Cell(3,0,0),Cell(3,1,\"f1, f2, f5\"),Cell(4,0,0),Cell(4,1,\"f1, f2\")),Seq(RowLabel(1, \"TRAIN\")),Seq(), Seq(1,5), Seq(0,1))\n\nval m2 = Matrix(Seq(Cell(0,0,\"label\"),Cell(0,1,\"features\"),Cell(1,0,1),Cell(1,1,\"f1, f3, f4, f6\"),Cell(2,0,1),Cell(2,1,\"f3, f6\"),Cell(3,0,0),Cell(3,1,\"f1, f2, f5\"),Cell(4,0,0),Cell(4,1,\"f1, f2\"),Cell(5,0,\"???\"),Cell(5,1,\"f1, f3, f4\"),Cell(6,0,\"???\"),Cell(6,1,\"f2\")),Seq(RowLabel(1, \"TRAIN\"),RowLabel(5, \"TEST\")),Seq(), Seq(1,5), Seq(0,1))\n\n\n//val m2 = Matrix(Seq(Cell(1,0,1.0),Cell(1,1,\"Blah\")),Seq(RowLabel(1,\"row1\"),RowLabel(0,\"row2\")),Seq(ColLabel(1,\"col2\")), Seq(1))\n\nval matrices = Seq(m1,m2)\n\n\nMatrixRenderer.render(matrices,layout)", 25 | "extraFields" : { 26 | "showEditor" : "false", 27 | "aggregatedCells" : "[]" 28 | } 29 | } 30 | }, { 31 | "id" : 3, 32 | "compiler" : "section", 33 | "input" : { 34 | "sessionId" : null, 35 | "code" : "matrix", 36 | "extraFields" : { } 37 | } 38 | }, { 39 | "id" : 4, 40 | "compiler" : "markdown", 41 | "input" : { 42 | "sessionId" : null, 43 | "code" : "### Matrix Completion", 44 | "extraFields" : { } 45 | } 46 | }, { 47 | "id" : 5, 48 | "compiler" : "scala", 49 | "input" : { 50 | "sessionId" : null, 51 | "code" : "import uk.ac.ucl.cs.mr.acltutorial._\nimport MatrixRenderer._\n\nval layout = Layout(colHeaderSize=110, ch=45, cw=60, rowHeaderSize=100, numCols=9,numRows=8)\n\n//val m1 = Matrix(Seq(Cell(0,0,\"label\"),Cell(0,1,\"features\"),Cell(1,0,1),Cell(1,1,\"f1,f3,f4,f6\"),Cell(2,0,1),Cell(2,1,\"f3,f6\"),Cell(3,0,0),Cell(3,1,\"f1,f2,f5\"),Cell(4,0,0),Cell(4,1,\"f1,f2\")),Seq(),Seq(), Seq(1))\n\n//val m2 = Matrix(Seq(Cell(0,0,\"label\"),Cell(0,1,\"features\"),Cell(1,0,1),Cell(1,1,\"f1,f3,f4,f6\"),Cell(2,0,1),Cell(2,1,\"f3,f6\"),Cell(3,0,0),Cell(3,1,\"f1,f2,f5\"),Cell(4,0,0),Cell(4,1,\"f1,f2\"),Cell(5,0,\"?\"),Cell(5,1,\"f1,f3,f4\"),Cell(6,0,\"?\"),Cell(6,1,\"f2\")),Seq(),Seq(), Seq(1,5))\n\n\nval m2 = Matrix(Seq(Cell(0,1,1),Cell(0,2,1),Cell(0,3,0),Cell(0,4,1),Cell(0,5,1),Cell(0,6,0),Cell(0,7,1),\nCell(1,1,1),Cell(1,2,0),Cell(1,3,0),Cell(1,4,1),Cell(1,5,0),Cell(1,6,0),Cell(1,7,1),\nCell(2,1,0),Cell(2,2,1),Cell(2,3,1),Cell(2,4,0),Cell(2,5,0),Cell(2,6,1),Cell(2,7,0),\nCell(3,1,0),Cell(3,2,1),Cell(3,3,1),Cell(3,4,0),Cell(3,5,0),Cell(3,6,0),Cell(3,7,0),\nCell(4,1,\"???\"),Cell(4,2,1),Cell(4,3,0),Cell(4,4,1),Cell(4,5,1),Cell(4,6,0),Cell(4,7,0),\nCell(5,1,\"???\"),Cell(5,2,0),Cell(5,3,1),Cell(5,4,0),Cell(5,5,0),Cell(5,6,0),Cell(5,7,0)\n),\nSeq(RowLabel(0,\"TRAIN\"),RowLabel(4,\"TEST\")),Seq(ColLabel(1,\"label\"),ColLabel(2,\"feat1\"),ColLabel(3,\"feat2\"),ColLabel(4,\"feat3\"),ColLabel(5,\"feat4\"),ColLabel(6,\"feat5\"),ColLabel(7,\"feat6\")), Seq(0,4), Seq(0,2))\n\nval m3 = Matrix(Seq(Cell(0,1,1),Cell(0,2,1),Cell(0,3,0),Cell(0,4,1),Cell(0,5,1),Cell(0,6,0),Cell(0,7,1),\nCell(1,1,1),Cell(1,2,0),Cell(1,3,0),Cell(1,4,1),Cell(1,5,0),Cell(1,6,0),Cell(1,7,1),\nCell(2,1,0),Cell(2,2,1),Cell(2,3,1),Cell(2,4,0),Cell(2,5,0),Cell(2,6,1),Cell(2,7,0),\nCell(3,1,0),Cell(3,2,1),Cell(3,3,1),Cell(3,4,0),Cell(3,5,0),Cell(3,6,0),Cell(3,7,0),\nCell(4,1,\"???\"),Cell(4,2,1),Cell(4,3,0),Cell(4,4,1),Cell(4,5,1),Cell(4,6,0),Cell(4,7,0),\nCell(5,1,\"???\"),Cell(5,2,0),Cell(5,3,1),Cell(5,4,0),Cell(5,5,0),Cell(5,6,0),Cell(5,7,0),\nCell(6,2,1),Cell(6,3,0),Cell(6,4,0),Cell(6,5,1),Cell(6,6,0),Cell(6,7,0),\nCell(7,2,0),Cell(7,3,1),Cell(7,4,0),Cell(7,5,0),Cell(7,6,1),Cell(7,7,0)\n),\nSeq(RowLabel(0,\"TRAIN\"),RowLabel(4,\"TEST\"),RowLabel(6,\"UNLAB\")),Seq(ColLabel(1,\"label\"),ColLabel(2,\"feat1\"),ColLabel(3,\"feat2\"),ColLabel(4,\"feat3\"),ColLabel(5,\"feat4\"),ColLabel(6,\"feat5\"),ColLabel(7,\"feat6\")), Seq(0,4,6), Seq(0,2)\n)\n\nval m4 = Matrix(Seq(Cell(0,1,1),Cell(0,0,1),Cell(0,2,1),Cell(0,3,0),Cell(0,4,1),Cell(0,5,1),Cell(0,6,0),Cell(0,7,1),\nCell(1,1,1),Cell(1,0,0),Cell(1,2,0),Cell(1,3,0),Cell(1,4,1),Cell(1,5,0),Cell(1,6,0),Cell(1,7,1),\nCell(2,1,0),Cell(2,0,1),Cell(2,2,1),Cell(2,3,1),Cell(2,4,0),Cell(2,5,0),Cell(2,6,1),Cell(2,7,0),\nCell(3,1,0),Cell(3,0,0),Cell(3,2,1),Cell(3,3,1),Cell(3,4,0),Cell(3,5,0),Cell(3,6,0),Cell(3,7,0),\nCell(4,1,\"???\"),Cell(4,0,\"???\"),Cell(4,2,1),Cell(4,3,0),Cell(4,4,1),Cell(4,5,1),Cell(4,6,0),Cell(4,7,0),\nCell(5,1,\"???\"),Cell(5,0,\"???\"),Cell(5,2,0),Cell(5,3,1),Cell(5,4,0),Cell(5,5,0),Cell(5,6,0),Cell(5,7,0),\nCell(6,2,1),Cell(6,3,0),Cell(6,4,0),Cell(6,5,1),Cell(6,6,0),Cell(6,7,0),\nCell(7,2,0),Cell(7,3,1),Cell(7,4,0),Cell(7,5,0),Cell(7,6,1),Cell(7,7,0)\n),\nSeq(RowLabel(0,\"TRAIN\"),RowLabel(4,\"TEST\"),RowLabel(6,\"UNLAB\")),Seq(ColLabel(0,\"task1\"),ColLabel(1,\"task2\"),ColLabel(2,\"feat1\"),ColLabel(3,\"feat2\"),ColLabel(4,\"feat3\"),ColLabel(5,\"feat4\"),ColLabel(6,\"feat5\"),ColLabel(7,\"feat6\")), Seq(0,4,6), Seq(0,2))\n\nval m5 = Matrix(Seq(Cell(0,1,1),Cell(0,0,1),Cell(0,2,1),Cell(0,3,0),Cell(0,4,1),Cell(0,6,0),\nCell(1,1,1),Cell(1,0,0),Cell(1,4,1),Cell(1,5,0),Cell(1,6,0),Cell(1,7,1),\nCell(2,1,0),Cell(2,0,1),Cell(2,3,1),Cell(2,4,0),Cell(2,6,1),Cell(2,7,0),\nCell(3,1,0),Cell(3,0,0),Cell(3,2,1),Cell(3,5,0),Cell(3,6,0),Cell(3,7,0),\nCell(4,1,\"???\"),Cell(4,0,\"???\"),Cell(4,2,1),Cell(4,3,0),Cell(4,5,1),Cell(4,6,0),Cell(4,7,0),\nCell(5,1,\"???\"),Cell(5,0,\"???\"),Cell(5,2,0),Cell(5,3,1),Cell(5,5,0),\nCell(6,2,1),Cell(6,3,0),Cell(6,5,1),Cell(6,6,0),\nCell(7,2,0),Cell(7,3,1),Cell(7,4,0),Cell(7,5,0)\n),\nSeq(RowLabel(0,\"TRAIN\"),RowLabel(4,\"TEST\"),RowLabel(6,\"UNLAB\")),Seq(ColLabel(0,\"task1\"),ColLabel(1,\"task2\"),ColLabel(2,\"feat1\"),ColLabel(3,\"feat2\"),ColLabel(4,\"feat3\"),ColLabel(5,\"feat4\"),ColLabel(6,\"feat5\"),ColLabel(7,\"feat6\")), Seq(0,4,6), Seq(0,2))\n\n\nval matrices = Seq(m2,m3,m4,m5)\n\n\nMatrixRenderer.render(matrices,layout)", 52 | "extraFields" : { 53 | "showEditor" : "false", 54 | "aggregatedCells" : "[\"import uk.ac.ucl.cs.mr.acltutorial._\\nimport MatrixRenderer._\\n\\nval layout = Layout(colHeaderSize=60, ch=45, cw=150, rowHeaderSize=100, numCols=2,numRows=7)\\n\\nval m1 = Matrix(Seq(Cell(0,0,\\\"label\\\"),Cell(0,1,\\\"features\\\"),Cell(1,0,1),Cell(1,1,\\\"f1, f3, f4, f6\\\"),Cell(2,0,1),Cell(2,1,\\\"f3, f6\\\"),Cell(3,0,0),Cell(3,1,\\\"f1, f2, f5\\\"),Cell(4,0,0),Cell(4,1,\\\"f1, f2\\\")),Seq(RowLabel(1, \\\"TRAIN\\\")),Seq(), Seq(1,5), Seq(0,1))\\n\\nval m2 = Matrix(Seq(Cell(0,0,\\\"label\\\"),Cell(0,1,\\\"features\\\"),Cell(1,0,1),Cell(1,1,\\\"f1, f3, f4, f6\\\"),Cell(2,0,1),Cell(2,1,\\\"f3, f6\\\"),Cell(3,0,0),Cell(3,1,\\\"f1, f2, f5\\\"),Cell(4,0,0),Cell(4,1,\\\"f1, f2\\\"),Cell(5,0,\\\"???\\\"),Cell(5,1,\\\"f1, f3, f4\\\"),Cell(6,0,\\\"???\\\"),Cell(6,1,\\\"f2\\\")),Seq(RowLabel(1, \\\"TRAIN\\\"),RowLabel(5, \\\"TEST\\\")),Seq(), Seq(1,5), Seq(0,1))\\n\\n\\n//val m2 = Matrix(Seq(Cell(1,0,1.0),Cell(1,1,\\\"Blah\\\")),Seq(RowLabel(1,\\\"row1\\\"),RowLabel(0,\\\"row2\\\")),Seq(ColLabel(1,\\\"col2\\\")), Seq(1))\\n\\nval matrices = Seq(m1,m2)\\n\\n\\nMatrixRenderer.render(matrices,layout)\"]" 55 | } 56 | } 57 | }, { 58 | "id" : 6, 59 | "compiler" : "html", 60 | "input" : { 61 | "sessionId" : null, 62 | "code" : "
\n
Binary classification
Semi-supervised (transductive) learning
Multi-task learning
Missing data
\n
", 63 | "extraFields" : { } 64 | } 65 | }, { 66 | "id" : 7, 67 | "compiler" : "section", 68 | "input" : { 69 | "sessionId" : null, 70 | "code" : "notation", 71 | "extraFields" : { } 72 | } 73 | }, { 74 | "id" : 8, 75 | "compiler" : "markdown", 76 | "input" : { 77 | "sessionId" : null, 78 | "code" : "### Notation\n\n- Scalars: lower-case letters \\\\(v,m\\\\)\n\n- Vectors: boldface lower-case letters \\\\(\\mathbf{v}\\\\)\n$$ \\begin{pmatrix} v_{1} & v_{2} & \\cdots & v_{n} \\end{pmatrix}$$\n\n", 79 | "extraFields" : { 80 | "hide_output" : "false" 81 | } 82 | } 83 | }, { 84 | "id" : 9, 85 | "compiler" : "markdown", 86 | "input" : { 87 | "sessionId" : null, 88 | "code" : "- Matrices: boldface capital letters \\\\(\\mathbf{M}\\\\)\n$$ \\begin{pmatrix} m_{1,1} & m_{1,2} & \\cdots & m_{1,J} \\\\\\\nm_{2,1} & m_{2,2} & \\cdots & m_{2,J} \\\\\\\n\\vdots & \\vdots & \\ddots & \\vdots \\\\\\\nm_{I,1} & m_{I,2} & \\cdots & m_{I,J} \\end{pmatrix} $$\n\n- \\\\(i\\\\)th row of \\\\(\\mathbf{M}\\\\): \\\\\\(\\mathbf{m}_{i:}\\\\)\n- \\\\(j\\\\)th column of \\\\(\\mathbf{M}\\\\):\\\\(\\mathbf{m}_{:j}\\\\)", 89 | "extraFields" : { 90 | "fragment" : "true" 91 | } 92 | } 93 | }, { 94 | "id" : 10, 95 | "compiler" : "section", 96 | "input" : { 97 | "sessionId" : null, 98 | "code" : "algebra", 99 | "extraFields" : { } 100 | } 101 | }, { 102 | "id" : 11, 103 | "compiler" : "markdown", 104 | "input" : { 105 | "sessionId" : null, 106 | "code" : "### Vector Operations\n\n- the **inner product** between vectors \\\\(\\mathbf{u}\\in\\Re^L\\\\) and \\\\(\\mathbf{v}\\in\\Re^L\\\\)\n$$\\langle \\mathbf{u},\\mathbf{v} \\rangle := \\sum_{\\ell=1}^L u_{\\ell} v_\\ell$$\n\n- the **outer product** between vectors \\\\(\\mathbf{u}\\in\\Re^N\\\\) and \\\\(\\mathbf{v}\\in\\Re^M\\\\)\n\n$$\\mathbf{u} \\otimes \\mathbf{v} = \\begin{pmatrix} u_{1} \\\\\\ u_{2} \\\\\\ \\vdots \\\\\\ u_{N}\\end{pmatrix} \\otimes \\begin{pmatrix} v_{1} \\\\\\ v_{2} \\\\\\ \\vdots \\\\\\ v_{M}\\end{pmatrix} := \\begin{pmatrix} u_{1} v_{1} & u_{1} v_{2} & \\cdots & u_{1} v_{M} \\\\\\ u_{2} v_{1} & u_{2} v_{2} & \\cdots & u_{2} v_{M} \\\\\\ \\vdots & \\vdots & \\ddots & \\vdots \\\\\\ u_{N} v_{1} & u_{N} v_{2} & \\cdots & u_{N} v_{M} \\end{pmatrix}_{N\\times M}\n$$", 107 | "extraFields" : { } 108 | } 109 | }, { 110 | "id" : 12, 111 | "compiler" : "section", 112 | "input" : { 113 | "sessionId" : null, 114 | "code" : "algebra2", 115 | "extraFields" : { } 116 | } 117 | }, { 118 | "id" : 13, 119 | "compiler" : "markdown", 120 | "input" : { 121 | "sessionId" : null, 122 | "code" : "### Matrix Operations\n\n- the **inner product** for matrices \\\\(\\mathbf{U} \\in\\Re^{N\\times L} \\\\) and \\\\(\\mathbf{V} \\in \\Re^{L \\times M} \\\\)\n\n$$\\mathbf{U} \\mathbf{V}:= \\begin{pmatrix} \\sum_{\\ell}u_{1,\\ell} v_{\\ell,1} & \\sum_{\\ell}u_{1,\\ell} v_{\\ell,2} & \\cdots & \\sum_{\\ell}u_{1,\\ell} v_{\\ell,M} \\\\\\ \\sum_{\\ell}u_{2,\\ell} v_{\\ell,1} & \\sum_{\\ell}u_{2,\\ell} v_{\\ell,2} & \\cdots & \\sum_{\\ell}u_{2,\\ell} v_{\\ell,M} \\\\\\ \\vdots & \\vdots & \\ddots & \\vdots \\\\\\ \\sum_{\\ell}u_{N,\\ell} v_{\\ell,1} & \\sum_{\\ell}u_{N,\\ell} v_{\\ell,2} & \\cdots & \\sum_{\\ell}u_{N,\\ell} v_{\\ell,M} \\end{pmatrix}_{N,M}$$\n\n", 123 | "extraFields" : { } 124 | } 125 | }, { 126 | "id" : 14, 127 | "compiler" : "section", 128 | "input" : { 129 | "sessionId" : null, 130 | "code" : "algebra3", 131 | "extraFields" : { } 132 | } 133 | }, { 134 | "id" : 15, 135 | "compiler" : "markdown", 136 | "input" : { 137 | "sessionId" : null, 138 | "code" : "### Matrix Operations\n\n- the **outer product** for matrices \\\\(\\mathbf{U} \\in\\Re^{N\\times L} \\\\) and \\\\(\\mathbf{V} \\in \\Re^{M \\times L} \\\\)\n\n$$\\mathbf{U} \\otimes \\mathbf{V} := \\sum_{\\ell=1}^L \\mathbf{u}_{:\\ell} \\otimes \\mathbf{v}_{:\\ell}\\\\\\\n= \\mathbf{u}_{:1} \\otimes \\mathbf{v}_{:1} + \\mathbf{u}_{:2} \\otimes \\mathbf{v}_{:2} + \\cdots \\mathbf{u}_{:L} \\otimes \\mathbf{v}_{:L}\n$$\n", 139 | "extraFields" : { } 140 | } 141 | }, { 142 | "id" : 16, 143 | "compiler" : "section", 144 | "input" : { 145 | "sessionId" : null, 146 | "code" : "algebra4", 147 | "extraFields" : { } 148 | } 149 | }, { 150 | "id" : 17, 151 | "compiler" : "markdown", 152 | "input" : { 153 | "sessionId" : null, 154 | "code" : "### Matrix Operations\n\n- the element-wise **Hadamard product** for \\\\(\\mathbf{U},\\mathbf{V} \\in\\Re^{N\\times L} \\\\)\n\n$$\\mathbf{U} \\circ \\mathbf{V} := \\begin{pmatrix} u_{1,1} v_{1,1} & u_{1,2} v_{1,2} & \\cdots & u_{1,L} v_{1,L} \\\\\\ u_{2,1} v_{2,1} & u_{2,2} v_{2,2} & \\cdots & u_{2,L} v_{2,L} \\\\\\ \\vdots & \\vdots & \\ddots & \\vdots \\\\\\ u_{N,1} v_{N,1} & u_{N,2} v_{N,2} & \\cdots & u_{N,L} v_{N,L} \\end{pmatrix}_{N,L}\n$$\n", 155 | "extraFields" : { } 156 | } 157 | }, { 158 | "id" : 18, 159 | "compiler" : "section", 160 | "input" : { 161 | "sessionId" : null, 162 | "code" : "norms", 163 | "extraFields" : { } 164 | } 165 | }, { 166 | "id" : 19, 167 | "compiler" : "markdown", 168 | "input" : { 169 | "sessionId" : null, 170 | "code" : "### Norms\n\nCommonly used to define:\n\n- loss functions (how far we are from our objective)\n\n- regularizers (how large we allow our parameters to grow)\n\n**element-wise** \\\\(p\\\\)-norms:\n\n$$||\\mathbf{U}||_p := \\left(\\sum_{m=1}^M\\sum_{n=1}^N |u_{n,m}|^p \\right)^{1/p} $$\n\n**Frobenius norm** \\\\(||\\mathbf{U}||_F := ||\\mathbf{U}||_2\\\\)", 171 | "extraFields" : { } 172 | } 173 | }, { 174 | "id" : 20, 175 | "compiler" : "section", 176 | "input" : { 177 | "sessionId" : null, 178 | "code" : "norms2", 179 | "extraFields" : { } 180 | } 181 | }, { 182 | "id" : 21, 183 | "compiler" : "html", 184 | "input" : { 185 | "sessionId" : null, 186 | "code" : "

Norm example

\n\n\\(\\mathbf{U} = \\begin{pmatrix} u_1 & u_2 \\end{pmatrix}\\)
\n
\n\n
\n
\n\n
\n
\n\n
\n
", 187 | "extraFields" : { } 188 | } 189 | }, { 190 | "id" : 22, 191 | "compiler" : "section", 192 | "input" : { 193 | "sessionId" : null, 194 | "code" : "rank", 195 | "extraFields" : { } 196 | } 197 | }, { 198 | "id" : 23, 199 | "compiler" : "markdown", 200 | "input" : { 201 | "sessionId" : null, 202 | "code" : "### Matrix rank\n\nThe maximum number of linearly independent columns/rows\n\nFor matrix \\\\(\\mathbf{U}\\in\\Re^{N\\times M} \\\\):\n\n- if \\\\(N=M=0\\\\) then \\\\(rank(\\mathbf{U}) = 0 \\\\) \n- else \\\\(max(rank(\\mathbf{U})) = min(N,M)\\\\)\n", 203 | "extraFields" : { } 204 | } 205 | }, { 206 | "id" : 24, 207 | "compiler" : "markdown", 208 | "input" : { 209 | "sessionId" : null, 210 | "code" : "\n$$\nrank\n\\begin{pmatrix}\n1 & 2 & 3 \\\\\\\n2 & 3 & 5 \\\\\\\n3 & 4 & 7 \\\\\\\n4 & 5 & 9 \\\\\\\n\\end{pmatrix}=??\n$$", 211 | "extraFields" : { 212 | "fragment" : "true" 213 | } 214 | } 215 | }, { 216 | "id" : 25, 217 | "compiler" : "markdown", 218 | "input" : { 219 | "sessionId" : null, 220 | "code" : "
\nhint: \\(\\mathbf{u}_{:1} + \\mathbf{u}_{:2} = \\mathbf{u}_{:3} \\)\n
", 221 | "extraFields" : { 222 | "fragment" : "true" 223 | } 224 | } 225 | } ], 226 | "config" : { } 227 | } 228 | -------------------------------------------------------------------------------- /src/main/moro/03_nmf.json: -------------------------------------------------------------------------------- 1 | { 2 | "name" : "Non-Negative Matrix Factorization", 3 | "cells" : [ { 4 | "id" : 0, 5 | "compiler" : "section", 6 | "input" : { 7 | "sessionId" : null, 8 | "code" : "why", 9 | "extraFields" : { } 10 | } 11 | }, { 12 | "id" : 1, 13 | "compiler" : "markdown", 14 | "input" : { 15 | "sessionId" : null, 16 | "code" : "### Non-negativity\n\nLow-rank factors are commonly interpreted as:\n\n- topics\n- image features\n\n\n
\nhttp://nimfa.biolab.si/nimfa.examples.orl_images.html", 17 | "extraFields" : { } 18 | } 19 | }, { 20 | "id" : 2, 21 | "compiler" : "markdown", 22 | "input" : { 23 | "sessionId" : null, 24 | "code" : "> MF is commomly used to find how
each instance is composed of its parts;
Subtraction is often counter-intuitive", 25 | "extraFields" : { 26 | "fragment" : "true" 27 | } 28 | } 29 | }, { 30 | "id" : 3, 31 | "compiler" : "section", 32 | "input" : { 33 | "sessionId" : null, 34 | "code" : "demoNMF", 35 | "extraFields" : { } 36 | } 37 | }, { 38 | "id" : 4, 39 | "compiler" : "markdown", 40 | "input" : { 41 | "sessionId" : null, 42 | "code" : "###Non-negative MF vs MF", 43 | "extraFields" : { } 44 | } 45 | }, { 46 | "id" : 5, 47 | "compiler" : "scala", 48 | "input" : { 49 | "sessionId" : null, 50 | "code" : "import uk.ac.ucl.cs.mr.acltutorial.ManualMF._\nimport uk.ac.ucl.cs.mr.acltutorial.MatrixRenderer._\nimport uk.ac.ucl.cs.mr.acltutorial.Renderer._\nimport cc.factorie.la.{DenseTensor2, DenseTensor1}\nimport ml.wolfe.{Mat, Vect}\nimport ml.wolfe.util.Math._\nval layout = Layout(cw = 80, ch = 50, colHeaderSize = 150, rowHeaderSize=100)\n", 51 | "extraFields" : { 52 | "hide_output" : "true", 53 | "showEditor" : "false", 54 | "aggregatedCells" : "[]" 55 | } 56 | } 57 | }, { 58 | "id" : 6, 59 | "compiler" : "scala", 60 | "input" : { 61 | "sessionId" : null, 62 | "code" : "val n = 5\nval m = 5 \nval rand = new scala.util.Random(0)\nval rowNames = Seq(\"doc1\",\"doc2\",\"doc3\",\"doc4\",\"doc5\")\nval colNames = Seq(\"Greece\",\"Tsipras\",\"Germany\",\"crisis\",\"economy\")\nval names = header(rowNames,colNames)\nval rls = Matrix(hRulers = Seq(0,5), vRulers = Seq(0,5))\nval M = parseMatrix(\n \"\"\"1 2 0 0 0\n 0 0 1 0 0\n 0 0 0 1 1 \n 0 0 1 1 1\n 1 2 1 1 0\"\"\")\n \ndef optimizeL2(M: Mat, K: Int, iters: Int, alpha:Double = 0.1, initScale:Double = 1.0): (Seq[Vect], Seq[Vect]) = {\n val rand = new scala.util.Random(0)\n val AV = initialAV(K, M.dim1, M.dim2, initScale)\n val A = AV._1; val V = AV._2\n def update(i: Int, j: Int) = {\n val a = A(i).copy\n val v = V(j).copy\n val y = a dot v\n A(i) += v * alpha * (M(i, j) - y)\n V(j) += a * alpha * (M(i, j) - y)\n }\n for (i <- Range(0,iters).toList) {\n update(rand.nextInt(M.dim1), \n rand.nextInt(M.dim2))\n }\n (A, V)\n}", 63 | "extraFields" : { 64 | "hide_output" : "true", 65 | "showEditor" : "false", 66 | "aggregatedCells" : "[\"import uk.ac.ucl.cs.mr.acltutorial.ManualMF._\\nimport uk.ac.ucl.cs.mr.acltutorial.MatrixRenderer._\\nimport uk.ac.ucl.cs.mr.acltutorial.Renderer._\\nimport cc.factorie.la.{DenseTensor2, DenseTensor1}\\nimport ml.wolfe.{Mat, Vect}\\nimport ml.wolfe.util.Math._\\nval layout = Layout(cw = 80, ch = 50, colHeaderSize = 150, rowHeaderSize=100)\\n\"]" 67 | } 68 | } 69 | }, { 70 | "id" : 7, 71 | "compiler" : "scala", 72 | "input" : { 73 | "sessionId" : null, 74 | "code" : "\nval (_A,_V) = nmf(M, 2, 10)\nval m1 = opacity(matrix(M) + names,0,2) + rls\n//val m1 = opacity(matrix(M) + names,0,2).addRectClass(Set(4 -> 4),\"red-box\") + rls\nval nmfOpaq = opacity(matrix(dots(_A,_V)) + embeddings(_A,_V) + names,0,2) +rls\nval nmfNums = opacity(matrix(dots(_A,_V)),0,2) + numbers(embeddings(_A,_V)) + names +rls\n//val m4 = numbers(matrix(dots(_A,_V)).addTextClass(Set(4 -> 4),\"red-text\") + names) +rls\nval (u,v) = optimizeL2(M,2,1000)\nval Mhat = dots(u,v)\nval MFrecon = opacity(matrix(Mhat), 0,2) + numbers(embeddings(u,v)) + names +rls\n\nval (_A4, _V4) = nmf(M, 2, 10)\nval nmfOpaq4 = opacity(matrix(dots(_A4,_V4)) + names,0,2) +rls\n\nval (u4,v4) = optimizeL2(M,4,10000)\nval Mhat4 = dots(u4,v4)\nval MFrecon4 = opacity(matrix(Mhat4), 0,2) + names +rls\n\n\nrender(Seq(m1,nmfNums, MFrecon, nmfOpaq4, MFrecon4),layout)", 75 | "extraFields" : { 76 | "showEditor" : "false", 77 | "aggregatedCells" : "[\"import uk.ac.ucl.cs.mr.acltutorial.ManualMF._\\nimport uk.ac.ucl.cs.mr.acltutorial.MatrixRenderer._\\nimport uk.ac.ucl.cs.mr.acltutorial.Renderer._\\nimport cc.factorie.la.{DenseTensor2, DenseTensor1}\\nimport ml.wolfe.{Mat, Vect}\\nimport ml.wolfe.util.Math._\\nval layout = Layout(cw = 80, ch = 50, colHeaderSize = 150, rowHeaderSize=100)\\n\",\"val n = 5\\nval m = 5 \\nval rand = new scala.util.Random(0)\\nval rowNames = Seq(\\\"doc1\\\",\\\"doc2\\\",\\\"doc3\\\",\\\"doc4\\\",\\\"doc5\\\")\\nval colNames = Seq(\\\"Greece\\\",\\\"Tsipras\\\",\\\"Germany\\\",\\\"crisis\\\",\\\"economy\\\")\\nval names = header(rowNames,colNames)\\nval rls = Matrix(hRulers = Seq(0,5), vRulers = Seq(0,5))\\nval M = parseMatrix(\\n \\\"\\\"\\\"1 2 0 0 0\\n 0 0 1 0 0\\n 0 0 0 1 1 \\n 0 0 1 1 1\\n 1 2 1 1 0\\\"\\\"\\\")\\n \\ndef optimizeL2(M: Mat, K: Int, iters: Int, alpha:Double = 0.1, initScale:Double = 1.0): (Seq[Vect], Seq[Vect]) = {\\n val rand = new scala.util.Random(0)\\n val AV = initialAV(K, M.dim1, M.dim2, initScale)\\n val A = AV._1; val V = AV._2\\n def update(i: Int, j: Int) = {\\n val a = A(i).copy\\n val v = V(j).copy\\n val y = a dot v\\n A(i) += v * alpha * (M(i, j) - y)\\n V(j) += a * alpha * (M(i, j) - y)\\n }\\n for (i <- Range(0,iters).toList) {\\n update(rand.nextInt(M.dim1), \\n rand.nextInt(M.dim2))\\n }\\n (A, V)\\n}\"]" 78 | } 79 | } 80 | }, { 81 | "id" : 8, 82 | "compiler" : "html", 83 | "input" : { 84 | "sessionId" : null, 85 | "code" : "
\n
Document-term matrix
NMF reconstruction
MF reconsruction
\n
rank-4 NMF reconstruction
\n
rank-4 MF reconstruction
\n
\n
\n", 86 | "extraFields" : { } 87 | } 88 | }, { 89 | "id" : 9, 90 | "compiler" : "section", 91 | "input" : { 92 | "sessionId" : null, 93 | "code" : "definition", 94 | "extraFields" : { } 95 | } 96 | }, { 97 | "id" : 10, 98 | "compiler" : "markdown", 99 | "input" : { 100 | "sessionId" : null, 101 | "code" : "### Definition\n\n\n\nGiven \\\\(\\mathbf{Y} \\in\\Re^{N\\times M}\\\\) \\\\(\\geq 0 \\\\)\n\nfind \\\\(\\mathbf{U} \\in\\Re^{N\\times L}\\\\) \\\\(\\geq 0\\\\)   and   \\\\(\\mathbf{V} \\in\\Re^{M\\times L}\\\\) \\\\(\\geq 0\\\\)\n\nso that \\\\(\\mathbf{Y} \\approx \\mathbf{U}\\mathbf{V}^{T}\\\\)\n", 102 | "extraFields" : { } 103 | } 104 | }, { 105 | "id" : 11, 106 | "compiler" : "markdown", 107 | "input" : { 108 | "sessionId" : null, 109 | "code" : "\n> NMF is additive mixture/(soft) clustering ", 110 | "extraFields" : { } 111 | } 112 | }, { 113 | "id" : 12, 114 | "compiler" : "section", 115 | "input" : { 116 | "sessionId" : null, 117 | "code" : "algos", 118 | "extraFields" : { } 119 | } 120 | }, { 121 | "id" : 13, 122 | "compiler" : "markdown", 123 | "input" : { 124 | "sessionId" : null, 125 | "code" : "### Basic NMF algorithm\n\nMultiplicative update rules to minimize \\\\(||\\mathbf{Y} - \\mathbf{U}\\mathbf{V}^{T}||^2 _2\\\\):\n\n$$u_{n,l} = u_{n,l} \\frac{(\\mathbf{Y}\\mathbf{V})_{n,l}}{(\\mathbf{U}\\mathbf{V}^{T}\\mathbf{V})_{n,l}} $$ \n\n$$v_{m,l} = v_{m,l} \\frac{(\\mathbf{Y}^T\\mathbf{U})_{m,l}}{(\\mathbf{V}\\mathbf{U}^T\\mathbf{U})_{m,l}} $$\n\n
\nLee and Seung (2001)\n
", 126 | "extraFields" : { } 127 | } 128 | }, { 129 | "id" : 14, 130 | "compiler" : "markdown", 131 | "input" : { 132 | "sessionId" : null, 133 | "code" : "\n> Recent work have switched to constrained Alternating Least Squares optimization\n\n\n
\nKim and Park (2008)\n
\n", 134 | "extraFields" : { 135 | "fragment" : "true" 136 | } 137 | } 138 | }, { 139 | "id" : 15, 140 | "compiler" : "section", 141 | "input" : { 142 | "sessionId" : null, 143 | "code" : "prob", 144 | "extraFields" : { } 145 | } 146 | }, { 147 | "id" : 16, 148 | "compiler" : "markdown", 149 | "input" : { 150 | "sessionId" : null, 151 | "code" : "### NMF with KL divergence\n\nAssume that \\\\(\\mathbf{Y}\\\\) represents a probability distribution \n$$\\sum_{n,m} y_{n,m} = 1$$\n\nMinimize the Kullback-Leibler divergence:\n\n$$ KL_{div}(\\mathbf{Y}||\\mathbf{U}\\mathbf{V}^{T}) = \\sum_{n,m}(y_{n,m}\\log\\frac{y_{n,m}}{(\\mathbf{U}\\mathbf{V}^{T})_{n,m}} ) $$\n\n- results in similar multiplicative updates\n- ensures that \\\\(\\mathbf{U}\\\\) and \\\\(\\mathbf{V}\\\\) also represent probability distributions\n\n", 152 | "extraFields" : { } 153 | } 154 | }, { 155 | "id" : 17, 156 | "compiler" : "section", 157 | "input" : { 158 | "sessionId" : null, 159 | "code" : "topic", 160 | "extraFields" : { } 161 | } 162 | }, { 163 | "id" : 18, 164 | "compiler" : "markdown", 165 | "input" : { 166 | "sessionId" : null, 167 | "code" : "### Probabilistic Latent Semantic Analysis\n\n$$ y_{n,m} = P(n,m) \\\\\\\n= \\sum_{l} P(l) P(m|l) P(n|l)\n$$\n\nwhere \\\\(n\\\\) is a document, \\\\(m\\\\) a word and \\\\(l\\\\) a component.\n", 168 | "extraFields" : { } 169 | } 170 | }, { 171 | "id" : 19, 172 | "compiler" : "markdown", 173 | "input" : { 174 | "sessionId" : null, 175 | "code" : "\n$$ \\dots = u^\\prime_{n,l} v^{\\prime}_{l,m} $$\n\nwhere \\\\(u^\\prime_{n,l} = P(l) P(n|l) \\\\) and \\\\(v^{\\prime}_{l,m} = P(m|l) \\\\)\n", 176 | "extraFields" : { 177 | "fragment" : "true" 178 | } 179 | } 180 | }, { 181 | "id" : 20, 182 | "compiler" : "section", 183 | "input" : { 184 | "sessionId" : null, 185 | "code" : "topic2", 186 | "extraFields" : { } 187 | } 188 | }, { 189 | "id" : 21, 190 | "compiler" : "markdown", 191 | "input" : { 192 | "sessionId" : null, 193 | "code" : "### Probabilistic Latent Semantic Analysis\n\n$$\\mathbf{Y} \\approx \\mathbf{U}\\mathbf{V}^{T} = (\\mathbf{U}\\mathbf{A}^{-1}\\mathbf{A})(\\mathbf{V}\\mathbf{B}^{-1}\\mathbf{B})^T\\\\\\ = (\\mathbf{U}\\mathbf{A}^{-1})(\\mathbf{A}\\mathbf{B})(\\mathbf{V}\\mathbf{B}^{-1})^T $$\n\n
\nwhere \\(\\mathbf{A}=diag(\\sum_n v_{n,1},\\dots,\\sum_n v_{n,L}) \\)
\nand \\(\\mathbf{B}=diag(\\sum_m u_{m,1},\\dots,\\sum_m u_{m,L}) \\)\n
\n\n\n\n", 194 | "extraFields" : { } 195 | } 196 | }, { 197 | "id" : 22, 198 | "compiler" : "markdown", 199 | "input" : { 200 | "sessionId" : null, 201 | "code" : "
\n> pLSA uses EM for parameter estimation and can converge to different local optima of the same objective as NMF-KL.\n\n
\nGaussier and Goutte (2005)\n
", 202 | "extraFields" : { } 203 | } 204 | }, { 205 | "id" : 23, 206 | "compiler" : "section", 207 | "input" : { 208 | "sessionId" : null, 209 | "code" : "lda", 210 | "extraFields" : { 211 | "hide_output" : "false" 212 | } 213 | } 214 | }, { 215 | "id" : 24, 216 | "compiler" : "markdown", 217 | "input" : { 218 | "sessionId" : null, 219 | "code" : "### Latent Dirichlet Allocation\n\n", 220 | "extraFields" : { } 221 | } 222 | }, { 223 | "id" : 25, 224 | "compiler" : "section", 225 | "input" : { 226 | "sessionId" : null, 227 | "code" : "ldamore", 228 | "extraFields" : { } 229 | } 230 | }, { 231 | "id" : 26, 232 | "compiler" : "markdown", 233 | "input" : { 234 | "sessionId" : null, 235 | "code" : "### Generative story\n\n- For each topic \\\\(l\\\\)\n - draw multinomial over words \\\\(\\mathbf{v}_{:l}\\in\\Re^M\\\\) from \\\\(Dir(\\beta)\\\\)\n- For each document \\\\(n\\\\)\n - draw multinomial over topics \\\\(\\mathbf{u}_{n:}\\in\\Re^L\\\\) from \\\\(Dir(\\alpha)\\\\)\n - for each word \\\\(i\\\\)\n - sample a topic assignment \\\\(z_i \\\\) from \\\\(\\mathbf{u}_{n:}\\\\)\n - sample a word \\\\(w_i \\\\) from \\\\(\\mathbf{v}_{:z_i}\\\\)\n\n", 236 | "extraFields" : { } 237 | } 238 | }, { 239 | "id" : 27, 240 | "compiler" : "markdown", 241 | "input" : { 242 | "sessionId" : null, 243 | "code" : "> Given the row-normalized document-term matrix \\\\(\\mathbf{Y}\\\\), find the factors \\\\(\\mathbf{U}\\\\) and \\\\(\\mathbf{V}\\\\) that reconstruct it.\n\n
\nArora et al (2012)\n
", 244 | "extraFields" : { 245 | "fragment" : "true" 246 | } 247 | } 248 | }, { 249 | "id" : 28, 250 | "compiler" : "section", 251 | "input" : { 252 | "sessionId" : null, 253 | "code" : "Summary", 254 | "extraFields" : { } 255 | } 256 | }, { 257 | "id" : 29, 258 | "compiler" : "markdown", 259 | "input" : { 260 | "sessionId" : null, 261 | "code" : "###Summary\n\n- Saw the matrix\n\n- Refresher on matrix rank and norms\n\n- Standard approaches to MF\n\n- Non-negative MF and connections to pLSA and LDA\n", 262 | "extraFields" : { } 263 | } 264 | } ], 265 | "config" : { } 266 | } 267 | -------------------------------------------------------------------------------- /src/main/moro/04_binarymf.json: -------------------------------------------------------------------------------- 1 | { 2 | "name" : "Binary Matrix Factorization", 3 | "cells" : [ { 4 | "id" : 0, 5 | "compiler" : "section", 6 | "input" : { 7 | "sessionId" : null, 8 | "code" : "Slide1", 9 | "extraFields" : { } 10 | } 11 | }, { 12 | "id" : 1, 13 | "compiler" : "markdown", 14 | "input" : { 15 | "sessionId" : null, 16 | "code" : "### Binary Data", 17 | "extraFields" : { } 18 | } 19 | }, { 20 | "id" : 2, 21 | "compiler" : "scala", 22 | "input" : { 23 | "sessionId" : null, 24 | "code" : "import uk.ac.ucl.cs.mr.acltutorial._\nimport MatrixRenderer._\nimport math._\n\ndef format(vect:Double) = f\"$vect%2.2f\"\n\nval layout = Layout(\n colHeaderSize=170, rowHeaderSize=220,\n ch=50, cw=100)\nval random = new scala.util.Random(1)\nval n = 4\nval docRows = for (row <- 0 until n) yield RowLabel(row, \"Doc\" + (row + 1))\nval docCells = for (row <- 0 until n; col <- 0 until n) yield Cell(row,col,format(random.nextGaussian() + 2.0))\nval docCols = Seq(\n ColLabel(0,\"the\"),\n ColLabel(1,\"black\"),\n ColLabel(2,\"cat\"),\n ColLabel(3,\"sat\")\n )\n\nval docMatrix = Matrix(docCells,docRows,docCols)\n\nval graphRows = Seq(\n RowLabel(0,\"(Blunsom,Oxford)\"),\n RowLabel(1,\"(Clark,Cambridge)\"),\n RowLabel(2,\"(Riedel,UCL)\"), \n RowLabel(3,\"(Vlachos,Sheffield)\")\n)\n\nval graphCells = for (row <- 0 until n; col <- 0 until n) yield Cell(row,col,f\"${random.nextInt(2)}\")\nval graphCols = Seq(\n ColLabel(0,\"worksFor\"),\n ColLabel(1,\"lecturerAt\"),\n ColLabel(2,\"affiliatedWith\"),\n ColLabel(3,\"profAt\")\n)\n\n\nval graphMatrix = Matrix(graphCells,graphRows,graphCols)\n//render the matrices\nrender(Seq(docMatrix,graphMatrix),layout)", 25 | "extraFields" : { 26 | "showEditor" : "false", 27 | "aggregatedCells" : "[]" 28 | } 29 | } 30 | }, { 31 | "id" : 4, 32 | "compiler" : "section", 33 | "input" : { 34 | "sessionId" : null, 35 | "code" : "24", 36 | "extraFields" : { } 37 | } 38 | }, { 39 | "id" : 5, 40 | "compiler" : "html", 41 | "input" : { 42 | "sessionId" : null, 43 | "code" : "

Logistic Loss

\n

Objective

\n$$\n\n \\sum_{(i,j)\\in\\Omega} \n \\log(\\class{fragment0 highlight-current-blue}{\\text{sigm} \\langle\\mathbf{u}_i,\\mathbf{v}_j\\rangle})^{y_{ij}} + \n \\log(\\class{fragment1 highlight-current-blue}{1-\\text{sigm} \\langle\\mathbf{u}_i,\\mathbf{v}_j\\rangle})^{1 - y_{ij}}\n$$\n\n\n
\n

Gradient Steps (for \\(y_{ij}=1 \\))

\n$$\n\\begin{split}\n\n\\mathbf{u}_i \\leftarrow \\mathbf{u}_i - \\eta \\text{sigm} \\langle\\mathbf{u}_i,\\mathbf{v}_j\\rangle \\mathbf{v}_j \\\\\n\n\\mathbf{v}_j \\leftarrow \\mathbf{v}_j - \\eta \\text{sigm} \\langle\\mathbf{u}_i,\\mathbf{v}_j\\rangle \\mathbf{u}_i\n\n\\end{split}\n$$\n
\n\n\n\n", 44 | "extraFields" : { } 45 | } 46 | }, { 47 | "id" : 6, 48 | "compiler" : "section", 49 | "input" : { 50 | "sessionId" : null, 51 | "code" : "logdemo", 52 | "extraFields" : { } 53 | } 54 | }, { 55 | "id" : 7, 56 | "compiler" : "scala", 57 | "input" : { 58 | "sessionId" : null, 59 | "code" : "import uk.ac.ucl.cs.mr.acltutorial.ManualMF._\nimport uk.ac.ucl.cs.mr.acltutorial.MatrixRenderer._\nimport uk.ac.ucl.cs.mr.acltutorial.Renderer._\nimport cc.factorie.la.{DenseTensor2, DenseTensor1}\nimport ml.wolfe.{Mat, Vect}\nimport ml.wolfe.util.Math._\nval layout = Layout(cw = 80, ch = 50, colHeaderSize = 150, rowHeaderSize = 90)\nval rand = new scala.util.Random(0)\nval rowNames = Seq(\"Nikos\",\"Anna\",\"Ivan\",\"Rex\",\"Hal\")\nval colNames = Seq(\"greek\",\"european\",\"human\",\"mammal\",\"entity\")\nval names = header(rowNames,colNames)\nval M = parseMatrix(\n \"\"\"1 1 1 1 1\n 0 1 1 1 1\n 0 0 1 1 0 \n 0 0 0 1 1\n 0 0 0 0 1\"\"\")", 60 | "extraFields" : { 61 | "hide" : "true", 62 | "hide_output" : "true", 63 | "showEditor" : "false", 64 | "aggregatedCells" : "[\"import uk.ac.ucl.cs.mr.acltutorial._\\nimport MatrixRenderer._\\nimport math._\\n\\ndef format(vect:Double) = f\\\"$vect%2.2f\\\"\\n\\nval layout = Layout(\\n colHeaderSize=170, rowHeaderSize=220,\\n ch=50, cw=100)\\nval random = new scala.util.Random(1)\\nval n = 4\\nval docRows = for (row <- 0 until n) yield RowLabel(row, \\\"Doc\\\" + (row + 1))\\nval docCells = for (row <- 0 until n; col <- 0 until n) yield Cell(row,col,format(random.nextGaussian() + 2.0))\\nval docCols = Seq(\\n ColLabel(0,\\\"the\\\"),\\n ColLabel(1,\\\"black\\\"),\\n ColLabel(2,\\\"cat\\\"),\\n ColLabel(3,\\\"sat\\\")\\n )\\n\\nval docMatrix = Matrix(docCells,docRows,docCols)\\n\\nval graphRows = Seq(\\n RowLabel(0,\\\"(Blunsom,Oxford)\\\"),\\n RowLabel(1,\\\"(Clark,Cambridge)\\\"),\\n RowLabel(2,\\\"(Riedel,UCL)\\\"), \\n RowLabel(3,\\\"(Vlachos,Sheffield)\\\")\\n)\\n\\nval graphCells = for (row <- 0 until n; col <- 0 until n) yield Cell(row,col,f\\\"${random.nextInt(2)}\\\")\\nval graphCols = Seq(\\n ColLabel(0,\\\"worksFor\\\"),\\n ColLabel(1,\\\"lecturerAt\\\"),\\n ColLabel(2,\\\"affiliatedWith\\\"),\\n ColLabel(3,\\\"profAt\\\")\\n)\\n\\n\\nval graphMatrix = Matrix(graphCells,graphRows,graphCols)\\n//render the matrices\\nrender(Seq(docMatrix,graphMatrix),layout)\"]" 65 | } 66 | } 67 | }, { 68 | "id" : 8, 69 | "compiler" : "scala", 70 | "input" : { 71 | "sessionId" : null, 72 | "code" : "val k = 2\nval m1 = opacity(matrix(M),0,1) + names \nval (a,v) = optimizeL2(M, k, 1000)\nval m2 = opacity(matrix(dots(a,v)),0,1) + names\nrender(Seq(m1,m2),layout) ", 73 | "extraFields" : { 74 | "aggregatedCells" : "[\"import uk.ac.ucl.cs.mr.acltutorial._\\nimport MatrixRenderer._\\nimport math._\\n\\ndef format(vect:Double) = f\\\"$vect%2.2f\\\"\\n\\nval layout = Layout(\\n colHeaderSize=170, rowHeaderSize=220,\\n ch=50, cw=100)\\nval random = new scala.util.Random(1)\\nval n = 4\\nval docRows = for (row <- 0 until n) yield RowLabel(row, \\\"Doc\\\" + (row + 1))\\nval docCells = for (row <- 0 until n; col <- 0 until n) yield Cell(row,col,format(random.nextGaussian() + 2.0))\\nval docCols = Seq(\\n ColLabel(0,\\\"the\\\"),\\n ColLabel(1,\\\"black\\\"),\\n ColLabel(2,\\\"cat\\\"),\\n ColLabel(3,\\\"sat\\\")\\n )\\n\\nval docMatrix = Matrix(docCells,docRows,docCols)\\n\\nval graphRows = Seq(\\n RowLabel(0,\\\"(Blunsom,Oxford)\\\"),\\n RowLabel(1,\\\"(Clark,Cambridge)\\\"),\\n RowLabel(2,\\\"(Riedel,UCL)\\\"), \\n RowLabel(3,\\\"(Vlachos,Sheffield)\\\")\\n)\\n\\nval graphCells = for (row <- 0 until n; col <- 0 until n) yield Cell(row,col,f\\\"${random.nextInt(2)}\\\")\\nval graphCols = Seq(\\n ColLabel(0,\\\"worksFor\\\"),\\n ColLabel(1,\\\"lecturerAt\\\"),\\n ColLabel(2,\\\"affiliatedWith\\\"),\\n ColLabel(3,\\\"profAt\\\")\\n)\\n\\n\\nval graphMatrix = Matrix(graphCells,graphRows,graphCols)\\n//render the matrices\\nrender(Seq(docMatrix,graphMatrix),layout)\",\"import uk.ac.ucl.cs.mr.acltutorial.ManualMF._\\nimport uk.ac.ucl.cs.mr.acltutorial.MatrixRenderer._\\nimport uk.ac.ucl.cs.mr.acltutorial.Renderer._\\nimport cc.factorie.la.{DenseTensor2, DenseTensor1}\\nimport ml.wolfe.{Mat, Vect}\\nimport ml.wolfe.util.Math._\\nval layout = Layout(cw = 80, ch = 50, colHeaderSize = 150, rowHeaderSize = 90)\\nval rand = new scala.util.Random(0)\\nval rowNames = Seq(\\\"Nikos\\\",\\\"Anna\\\",\\\"Ivan\\\",\\\"Rex\\\",\\\"Hal\\\")\\nval colNames = Seq(\\\"greek\\\",\\\"european\\\",\\\"human\\\",\\\"mammal\\\",\\\"entity\\\")\\nval names = header(rowNames,colNames)\\nval M = parseMatrix(\\n \\\"\\\"\\\"1 1 1 1 1\\n 0 1 1 1 1\\n 0 0 1 1 0 \\n 0 0 0 1 1\\n 0 0 0 0 1\\\"\\\"\\\")\"]" 75 | } 76 | } 77 | }, { 78 | "id" : 9, 79 | "compiler" : "section", 80 | "input" : { 81 | "sessionId" : null, 82 | "code" : "logloss", 83 | "extraFields" : { } 84 | } 85 | }, { 86 | "id" : 10, 87 | "compiler" : "scala", 88 | "input" : { 89 | "sessionId" : null, 90 | "code" : "def optimizeLogistic(M: Mat, K: Int, iters: Int, alpha:Double = 0.1, initScale:Double = 1.0): (Seq[Vect], Seq[Vect]) = {\n val rand = new scala.util.Random(0)\n val AV = initialAV(K, M.dim1, M.dim2, initScale)\n val A = AV._1; val V = AV._2\n def update(i: Int, j: Int) = {\n val a = A(i).copy\n val v = V(j).copy\n val p = sigmoid(a dot v)\n A(i) += v * alpha * (M(i, j) - p)\n V(j) += a * alpha * (M(i, j) - p)\n }\n for (i <- Range(0,iters).toList) {\n update(rand.nextInt(M.dim1), \n rand.nextInt(M.dim2))\n }\n (A, V)\n}\n\"\"", 91 | "extraFields" : { 92 | "aggregatedCells" : "[\"import uk.ac.ucl.cs.mr.acltutorial._\\nimport MatrixRenderer._\\nimport math._\\n\\ndef format(vect:Double) = f\\\"$vect%2.2f\\\"\\n\\nval layout = Layout(\\n colHeaderSize=170, rowHeaderSize=220,\\n ch=50, cw=100)\\nval random = new scala.util.Random(1)\\nval n = 4\\nval docRows = for (row <- 0 until n) yield RowLabel(row, \\\"Doc\\\" + (row + 1))\\nval docCells = for (row <- 0 until n; col <- 0 until n) yield Cell(row,col,format(random.nextGaussian() + 2.0))\\nval docCols = Seq(\\n ColLabel(0,\\\"the\\\"),\\n ColLabel(1,\\\"black\\\"),\\n ColLabel(2,\\\"cat\\\"),\\n ColLabel(3,\\\"sat\\\")\\n )\\n\\nval docMatrix = Matrix(docCells,docRows,docCols)\\n\\nval graphRows = Seq(\\n RowLabel(0,\\\"(Blunsom,Oxford)\\\"),\\n RowLabel(1,\\\"(Clark,Cambridge)\\\"),\\n RowLabel(2,\\\"(Riedel,UCL)\\\"), \\n RowLabel(3,\\\"(Vlachos,Sheffield)\\\")\\n)\\n\\nval graphCells = for (row <- 0 until n; col <- 0 until n) yield Cell(row,col,f\\\"${random.nextInt(2)}\\\")\\nval graphCols = Seq(\\n ColLabel(0,\\\"worksFor\\\"),\\n ColLabel(1,\\\"lecturerAt\\\"),\\n ColLabel(2,\\\"affiliatedWith\\\"),\\n ColLabel(3,\\\"profAt\\\")\\n)\\n\\n\\nval graphMatrix = Matrix(graphCells,graphRows,graphCols)\\n//render the matrices\\nrender(Seq(docMatrix,graphMatrix),layout)\",\"import uk.ac.ucl.cs.mr.acltutorial.ManualMF._\\nimport uk.ac.ucl.cs.mr.acltutorial.MatrixRenderer._\\nimport uk.ac.ucl.cs.mr.acltutorial.Renderer._\\nimport cc.factorie.la.{DenseTensor2, DenseTensor1}\\nimport ml.wolfe.{Mat, Vect}\\nimport ml.wolfe.util.Math._\\nval layout = Layout(cw = 80, ch = 50, colHeaderSize = 150, rowHeaderSize = 90)\\nval rand = new scala.util.Random(0)\\nval rowNames = Seq(\\\"Nikos\\\",\\\"Anna\\\",\\\"Ivan\\\",\\\"Rex\\\",\\\"Hal\\\")\\nval colNames = Seq(\\\"greek\\\",\\\"european\\\",\\\"human\\\",\\\"mammal\\\",\\\"entity\\\")\\nval names = header(rowNames,colNames)\\nval M = parseMatrix(\\n \\\"\\\"\\\"1 1 1 1 1\\n 0 1 1 1 1\\n 0 0 1 1 0 \\n 0 0 0 1 1\\n 0 0 0 0 1\\\"\\\"\\\")\",\"val k = 2\\nval m1 = opacity(matrix(M),0,1) + names \\nval (a,v) = optimizeL2(M, k, 1000)\\nval m2 = opacity(matrix(dots(a,v)),0,1) + names\\nrender(Seq(m1,m2),layout) \"]" 93 | } 94 | } 95 | }, { 96 | "id" : 11, 97 | "compiler" : "section", 98 | "input" : { 99 | "sessionId" : null, 100 | "code" : "logresults", 101 | "extraFields" : { } 102 | } 103 | }, { 104 | "id" : 12, 105 | "compiler" : "scala", 106 | "input" : { 107 | "sessionId" : null, 108 | "code" : "val (la,lv) = optimizeLogistic(M, 2, 1000, 0.1)\nval m3 = numbers(matrix(dots(la,lv)) + names)\nval m4 = numbers(matrix(sigm(dots(la,lv)))) + names\nval m5 = opacity(matrix(sigm(dots(la,lv))),0,1) + names\nval m6 = opacity(matrix(sigm(dots(la,lv))) + embeddings(la,lv),0,1) + names\nrender(Seq(m3,m4,m5,m6),layout)", 109 | "extraFields" : { 110 | "showEditor" : "false", 111 | "aggregatedCells" : "[\"import uk.ac.ucl.cs.mr.acltutorial._\\nimport MatrixRenderer._\\nimport math._\\n\\ndef format(vect:Double) = f\\\"$vect%2.2f\\\"\\n\\nval layout = Layout(\\n colHeaderSize=170, rowHeaderSize=220,\\n ch=50, cw=100)\\nval random = new scala.util.Random(1)\\nval n = 4\\nval docRows = for (row <- 0 until n) yield RowLabel(row, \\\"Doc\\\" + (row + 1))\\nval docCells = for (row <- 0 until n; col <- 0 until n) yield Cell(row,col,format(random.nextGaussian() + 2.0))\\nval docCols = Seq(\\n ColLabel(0,\\\"the\\\"),\\n ColLabel(1,\\\"black\\\"),\\n ColLabel(2,\\\"cat\\\"),\\n ColLabel(3,\\\"sat\\\")\\n )\\n\\nval docMatrix = Matrix(docCells,docRows,docCols)\\n\\nval graphRows = Seq(\\n RowLabel(0,\\\"(Blunsom,Oxford)\\\"),\\n RowLabel(1,\\\"(Clark,Cambridge)\\\"),\\n RowLabel(2,\\\"(Riedel,UCL)\\\"), \\n RowLabel(3,\\\"(Vlachos,Sheffield)\\\")\\n)\\n\\nval graphCells = for (row <- 0 until n; col <- 0 until n) yield Cell(row,col,f\\\"${random.nextInt(2)}\\\")\\nval graphCols = Seq(\\n ColLabel(0,\\\"worksFor\\\"),\\n ColLabel(1,\\\"lecturerAt\\\"),\\n ColLabel(2,\\\"affiliatedWith\\\"),\\n ColLabel(3,\\\"profAt\\\")\\n)\\n\\n\\nval graphMatrix = Matrix(graphCells,graphRows,graphCols)\\n//render the matrices\\nrender(Seq(docMatrix,graphMatrix),layout)\",\"import uk.ac.ucl.cs.mr.acltutorial.ManualMF._\\nimport uk.ac.ucl.cs.mr.acltutorial.MatrixRenderer._\\nimport uk.ac.ucl.cs.mr.acltutorial.Renderer._\\nimport cc.factorie.la.{DenseTensor2, DenseTensor1}\\nimport ml.wolfe.{Mat, Vect}\\nimport ml.wolfe.util.Math._\\nval layout = Layout(cw = 80, ch = 50, colHeaderSize = 150, rowHeaderSize = 90)\\nval rand = new scala.util.Random(0)\\nval rowNames = Seq(\\\"Nikos\\\",\\\"Anna\\\",\\\"Ivan\\\",\\\"Rex\\\",\\\"Hal\\\")\\nval colNames = Seq(\\\"greek\\\",\\\"european\\\",\\\"human\\\",\\\"mammal\\\",\\\"entity\\\")\\nval names = header(rowNames,colNames)\\nval M = parseMatrix(\\n \\\"\\\"\\\"1 1 1 1 1\\n 0 1 1 1 1\\n 0 0 1 1 0 \\n 0 0 0 1 1\\n 0 0 0 0 1\\\"\\\"\\\")\",\"val k = 2\\nval m1 = opacity(matrix(M),0,1) + names \\nval (a,v) = optimizeL2(M, k, 1000)\\nval m2 = opacity(matrix(dots(a,v)),0,1) + names\\nrender(Seq(m1,m2),layout) \",\"def optimizeLogistic(M: Mat, K: Int, iters: Int, alpha:Double = 0.1, initScale:Double = 1.0): (Seq[Vect], Seq[Vect]) = {\\n val rand = new scala.util.Random(0)\\n val AV = initialAV(K, M.dim1, M.dim2, initScale)\\n val A = AV._1; val V = AV._2\\n def update(i: Int, j: Int) = {\\n val a = A(i).copy\\n val v = V(j).copy\\n val p = sigmoid(a dot v)\\n A(i) += v * alpha * (M(i, j) - p)\\n V(j) += a * alpha * (M(i, j) - p)\\n }\\n for (i <- Range(0,iters).toList) {\\n update(rand.nextInt(M.dim1), \\n rand.nextInt(M.dim2))\\n }\\n (A, V)\\n}\\n\\\"\\\"\"]" 112 | } 113 | } 114 | }, { 115 | "id" : 13, 116 | "compiler" : "section", 117 | "input" : { 118 | "sessionId" : null, 119 | "code" : "identity", 120 | "extraFields" : { } 121 | } 122 | }, { 123 | "id" : 14, 124 | "compiler" : "markdown", 125 | "input" : { 126 | "sessionId" : null, 127 | "code" : "", 128 | "extraFields" : { } 129 | } 130 | }, { 131 | "id" : 15, 132 | "compiler" : "section", 133 | "input" : { 134 | "sessionId" : null, 135 | "code" : "sign1", 136 | "extraFields" : { } 137 | } 138 | }, { 139 | "id" : 16, 140 | "compiler" : "markdown", 141 | "input" : { 142 | "sessionId" : null, 143 | "code" : "### Sign-rank\n(Linial et al., 2007; Bouchard et al., 2015)\n\n", 144 | "extraFields" : { } 145 | } 146 | }, { 147 | "id" : 17, 148 | "compiler" : "section", 149 | "input" : { 150 | "sessionId" : null, 151 | "code" : "sign2", 152 | "extraFields" : { } 153 | } 154 | }, { 155 | "id" : 18, 156 | "compiler" : "markdown", 157 | "input" : { 158 | "sessionId" : null, 159 | "code" : "\n### Sign-rank\n(Linial et al., 2007; Bouchard et al., 2015)\n\n\n", 160 | "extraFields" : { } 161 | } 162 | }, { 163 | "id" : 19, 164 | "compiler" : "section", 165 | "input" : { 166 | "sessionId" : null, 167 | "code" : "sign3", 168 | "extraFields" : { } 169 | } 170 | }, { 171 | "id" : 20, 172 | "compiler" : "markdown", 173 | "input" : { 174 | "sessionId" : null, 175 | "code" : "\n### Sign-rank\n(Linial et al., 2007; Bouchard et al., 2015)\n\n", 176 | "extraFields" : { } 177 | } 178 | }, { 179 | "id" : 21, 180 | "compiler" : "section", 181 | "input" : { 182 | "sessionId" : null, 183 | "code" : "Slide3", 184 | "extraFields" : { } 185 | } 186 | }, { 187 | "id" : 22, 188 | "compiler" : "markdown", 189 | "input" : { 190 | "sessionId" : null, 191 | "code" : "### Negative Data", 192 | "extraFields" : { } 193 | } 194 | }, { 195 | "id" : 23, 196 | "compiler" : "scala", 197 | "input" : { 198 | "sessionId" : null, 199 | "code" : "import uk.ac.ucl.cs.mr.acltutorial.BinaryMF._\nval layout = Layout(\n colHeaderSize=170, rowHeaderSize=220,\n ch=50, cw=100)\n\nrender(Seq(allCells,noZeroes,someSampledZeroes,moreSampledZeroes),layout)", 200 | "extraFields" : { 201 | "showEditor" : "false", 202 | "aggregatedCells" : "[\"import uk.ac.ucl.cs.mr.acltutorial._\\nimport MatrixRenderer._\\nimport math._\\n\\ndef format(vect:Double) = f\\\"$vect%2.2f\\\"\\n\\nval layout = Layout(\\n colHeaderSize=170, rowHeaderSize=220,\\n ch=50, cw=100)\\nval random = new scala.util.Random(1)\\nval n = 4\\nval docRows = for (row <- 0 until n) yield RowLabel(row, \\\"Doc\\\" + (row + 1))\\nval docCells = for (row <- 0 until n; col <- 0 until n) yield Cell(row,col,format(random.nextGaussian() + 2.0))\\nval docCols = Seq(\\n ColLabel(0,\\\"the\\\"),\\n ColLabel(1,\\\"black\\\"),\\n ColLabel(2,\\\"cat\\\"),\\n ColLabel(3,\\\"sat\\\")\\n )\\n\\nval docMatrix = Matrix(docCells,docRows,docCols)\\n\\nval graphRows = Seq(\\n RowLabel(0,\\\"(Blunsom,Oxford)\\\"),\\n RowLabel(1,\\\"(Clark,Cambridge)\\\"),\\n RowLabel(2,\\\"(Riedel,UCL)\\\"), \\n RowLabel(3,\\\"(Vlachos,Sheffield)\\\")\\n)\\n\\nval graphCells = for (row <- 0 until n; col <- 0 until n) yield Cell(row,col,f\\\"${random.nextInt(2)}\\\")\\nval graphCols = Seq(\\n ColLabel(0,\\\"worksFor\\\"),\\n ColLabel(1,\\\"lecturerAt\\\"),\\n ColLabel(2,\\\"affiliatedWith\\\"),\\n ColLabel(3,\\\"profAt\\\")\\n)\\n\\n\\nval graphMatrix = Matrix(graphCells,graphRows,graphCols)\\n//render the matrices\\nrender(Seq(docMatrix,graphMatrix),layout)\",\"import uk.ac.ucl.cs.mr.acltutorial.ManualMF._\\nimport uk.ac.ucl.cs.mr.acltutorial.MatrixRenderer._\\nimport uk.ac.ucl.cs.mr.acltutorial.Renderer._\\nimport cc.factorie.la.{DenseTensor2, DenseTensor1}\\nimport ml.wolfe.{Mat, Vect}\\nimport ml.wolfe.util.Math._\\nval layout = Layout(cw = 80, ch = 50, colHeaderSize = 150, rowHeaderSize = 90)\\nval rand = new scala.util.Random(0)\\nval rowNames = Seq(\\\"Nikos\\\",\\\"Anna\\\",\\\"Ivan\\\",\\\"Rex\\\",\\\"Hal\\\")\\nval colNames = Seq(\\\"greek\\\",\\\"european\\\",\\\"human\\\",\\\"mammal\\\",\\\"entity\\\")\\nval names = header(rowNames,colNames)\\nval M = parseMatrix(\\n \\\"\\\"\\\"1 1 1 1 1\\n 0 1 1 1 1\\n 0 0 1 1 0 \\n 0 0 0 1 1\\n 0 0 0 0 1\\\"\\\"\\\")\",\"val k = 2\\nval m1 = opacity(matrix(M),0,1) + names \\nval (a,v) = optimizeL2(M, k, 1000)\\nval m2 = opacity(matrix(dots(a,v)),0,1) + names\\nrender(Seq(m1,m2),layout) \",\"def optimizeLogistic(M: Mat, K: Int, iters: Int, alpha:Double = 0.1, initScale:Double = 1.0): (Seq[Vect], Seq[Vect]) = {\\n val rand = new scala.util.Random(0)\\n val AV = initialAV(K, M.dim1, M.dim2, initScale)\\n val A = AV._1; val V = AV._2\\n def update(i: Int, j: Int) = {\\n val a = A(i).copy\\n val v = V(j).copy\\n val p = sigmoid(a dot v)\\n A(i) += v * alpha * (M(i, j) - p)\\n V(j) += a * alpha * (M(i, j) - p)\\n }\\n for (i <- Range(0,iters).toList) {\\n update(rand.nextInt(M.dim1), \\n rand.nextInt(M.dim2))\\n }\\n (A, V)\\n}\\n\\\"\\\"\",\"val (la,lv) = optimizeLogistic(M, 2, 1000, 0.1)\\nval m3 = numbers(matrix(dots(la,lv)) + names)\\nval m4 = numbers(matrix(sigm(dots(la,lv)))) + names\\nval m5 = opacity(matrix(sigm(dots(la,lv))),0,1) + names\\nval m6 = opacity(matrix(sigm(dots(la,lv))) + embeddings(la,lv),0,1) + names\\nrender(Seq(m3,m4,m5,m6),layout)\"]" 203 | } 204 | } 205 | }, { 206 | "id" : 24, 207 | "compiler" : "html", 208 | "input" : { 209 | "sessionId" : null, 210 | "code" : "\n", 211 | "extraFields" : { } 212 | } 213 | }, { 214 | "id" : 25, 215 | "compiler" : "section", 216 | "input" : { 217 | "sessionId" : null, 218 | "code" : "WeightedNeg", 219 | "extraFields" : { } 220 | } 221 | }, { 222 | "id" : 26, 223 | "compiler" : "markdown", 224 | "input" : { 225 | "sessionId" : null, 226 | "code" : "### Implicit Negative Training Data\n

\n\n$$\n \\sum_{(i,j)\\in\\Omega}\n \\omega_\\text{pos}\\log(\\text{sigm} \\langle\\mathbf{u}_i,\\mathbf{v}_j\\rangle)\n +$$\n$$\\sum_{(a,b)\\not\\in\\Omega} \\omega_\\text{neg}\\log\\left(1-\\text{sigm} \\langle\\mathbf{u}_a,\\mathbf{v}_b\\rangle\\right)\n$$", 227 | "extraFields" : { } 228 | } 229 | }, { 230 | "id" : 27, 231 | "compiler" : "section", 232 | "input" : { 233 | "sessionId" : null, 234 | "code" : "BPR", 235 | "extraFields" : { } 236 | } 237 | }, { 238 | "id" : 28, 239 | "compiler" : "markdown", 240 | "input" : { 241 | "sessionId" : null, 242 | "code" : "### Bayesian Personalized Ranking\n(Rendle et al, 2009)\n

\n\n$$\n \\sum_{(i,j)\\in\\Omega}\n \\sum_{(a,b)\\not\\in\\Omega} \n \\log\\left(\\text{sigm}(\\langle\\mathbf{u}_i,\\mathbf{v}_j\\rangle -\\langle\\mathbf{u}_a,\\mathbf{v}_b\\rangle)\\right)\n$$", 243 | "extraFields" : { } 244 | } 245 | }, { 246 | "id" : 29, 247 | "compiler" : "section", 248 | "input" : { 249 | "sessionId" : null, 250 | "code" : "Slide4", 251 | "extraFields" : { } 252 | } 253 | }, { 254 | "id" : 30, 255 | "compiler" : "markdown", 256 | "input" : { 257 | "sessionId" : null, 258 | "code" : "### Sample During SGD", 259 | "extraFields" : { } 260 | } 261 | }, { 262 | "id" : 31, 263 | "compiler" : "scala", 264 | "input" : { 265 | "sessionId" : null, 266 | "code" : "val layout = Layout(\n colHeaderSize=170, rowHeaderSize=220,\n ch=50, cw=100)\nrender(sgdUpdates,layout)", 267 | "extraFields" : { 268 | "showEditor" : "false", 269 | "aggregatedCells" : "[\"import uk.ac.ucl.cs.mr.acltutorial._\\nimport MatrixRenderer._\\nimport math._\\n\\ndef format(vect:Double) = f\\\"$vect%2.2f\\\"\\n\\nval layout = Layout(\\n colHeaderSize=170, rowHeaderSize=220,\\n ch=50, cw=100)\\nval random = new scala.util.Random(1)\\nval n = 4\\nval docRows = for (row <- 0 until n) yield RowLabel(row, \\\"Doc\\\" + (row + 1))\\nval docCells = for (row <- 0 until n; col <- 0 until n) yield Cell(row,col,format(random.nextGaussian() + 2.0))\\nval docCols = Seq(\\n ColLabel(0,\\\"the\\\"),\\n ColLabel(1,\\\"black\\\"),\\n ColLabel(2,\\\"cat\\\"),\\n ColLabel(3,\\\"sat\\\")\\n )\\n\\nval docMatrix = Matrix(docCells,docRows,docCols)\\n\\nval graphRows = Seq(\\n RowLabel(0,\\\"(Blunsom,Oxford)\\\"),\\n RowLabel(1,\\\"(Clark,Cambridge)\\\"),\\n RowLabel(2,\\\"(Riedel,UCL)\\\"), \\n RowLabel(3,\\\"(Vlachos,Sheffield)\\\")\\n)\\n\\nval graphCells = for (row <- 0 until n; col <- 0 until n) yield Cell(row,col,f\\\"${random.nextInt(2)}\\\")\\nval graphCols = Seq(\\n ColLabel(0,\\\"worksFor\\\"),\\n ColLabel(1,\\\"lecturerAt\\\"),\\n ColLabel(2,\\\"affiliatedWith\\\"),\\n ColLabel(3,\\\"profAt\\\")\\n)\\n\\n\\nval graphMatrix = Matrix(graphCells,graphRows,graphCols)\\n//render the matrices\\nrender(Seq(docMatrix,graphMatrix),layout)\",\"import uk.ac.ucl.cs.mr.acltutorial.ManualMF._\\nimport uk.ac.ucl.cs.mr.acltutorial.MatrixRenderer._\\nimport uk.ac.ucl.cs.mr.acltutorial.Renderer._\\nimport cc.factorie.la.{DenseTensor2, DenseTensor1}\\nimport ml.wolfe.{Mat, Vect}\\nimport ml.wolfe.util.Math._\\nval layout = Layout(cw = 80, ch = 50, colHeaderSize = 150, rowHeaderSize = 90)\\nval rand = new scala.util.Random(0)\\nval rowNames = Seq(\\\"Nikos\\\",\\\"Anna\\\",\\\"Ivan\\\",\\\"Rex\\\",\\\"Hal\\\")\\nval colNames = Seq(\\\"greek\\\",\\\"european\\\",\\\"human\\\",\\\"mammal\\\",\\\"entity\\\")\\nval names = header(rowNames,colNames)\\nval M = parseMatrix(\\n \\\"\\\"\\\"1 1 1 1 1\\n 0 1 1 1 1\\n 0 0 1 1 0 \\n 0 0 0 1 1\\n 0 0 0 0 1\\\"\\\"\\\")\",\"val k = 2\\nval m1 = opacity(matrix(M),0,1) + names \\nval (a,v) = optimizeL2(M, k, 1000)\\nval m2 = opacity(matrix(dots(a,v)),0,1) + names\\nrender(Seq(m1,m2),layout) \",\"def optimizeLogistic(M: Mat, K: Int, iters: Int, alpha:Double = 0.1, initScale:Double = 1.0): (Seq[Vect], Seq[Vect]) = {\\n val rand = new scala.util.Random(0)\\n val AV = initialAV(K, M.dim1, M.dim2, initScale)\\n val A = AV._1; val V = AV._2\\n def update(i: Int, j: Int) = {\\n val a = A(i).copy\\n val v = V(j).copy\\n val p = sigmoid(a dot v)\\n A(i) += v * alpha * (M(i, j) - p)\\n V(j) += a * alpha * (M(i, j) - p)\\n }\\n for (i <- Range(0,iters).toList) {\\n update(rand.nextInt(M.dim1), \\n rand.nextInt(M.dim2))\\n }\\n (A, V)\\n}\\n\\\"\\\"\",\"val (la,lv) = optimizeLogistic(M, 2, 1000, 0.1)\\nval m3 = numbers(matrix(dots(la,lv)) + names)\\nval m4 = numbers(matrix(sigm(dots(la,lv)))) + names\\nval m5 = opacity(matrix(sigm(dots(la,lv))),0,1) + names\\nval m6 = opacity(matrix(sigm(dots(la,lv))) + embeddings(la,lv),0,1) + names\\nrender(Seq(m3,m4,m5,m6),layout)\",\"import uk.ac.ucl.cs.mr.acltutorial.BinaryMF._\\nval layout = Layout(\\n colHeaderSize=170, rowHeaderSize=220,\\n ch=50, cw=100)\\n\\nrender(Seq(allCells,noZeroes,someSampledZeroes,moreSampledZeroes),layout)\"]" 270 | } 271 | } 272 | }, { 273 | "id" : 32, 274 | "compiler" : "html", 275 | "input" : { 276 | "sessionId" : null, 277 | "code" : "
\n
Sample Positive Cell
\n
Sample Negative Cell
\n
", 278 | "extraFields" : { } 279 | } 280 | }, { 281 | "id" : 33, 282 | "compiler" : "section", 283 | "input" : { 284 | "sessionId" : null, 285 | "code" : "App", 286 | "extraFields" : { } 287 | } 288 | }, { 289 | "id" : 34, 290 | "compiler" : "markdown", 291 | "input" : { 292 | "sessionId" : null, 293 | "code" : "### Application: Relation Extraction\n(Riedel et al, 2013)\n\n", 294 | "extraFields" : { } 295 | } 296 | }, { 297 | "id" : 35, 298 | "compiler" : "section", 299 | "input" : { 300 | "sessionId" : null, 301 | "code" : "USchema", 302 | "extraFields" : { } 303 | } 304 | }, { 305 | "id" : 36, 306 | "compiler" : "markdown", 307 | "input" : { 308 | "sessionId" : null, 309 | "code" : "
\n", 310 | "extraFields" : { } 311 | } 312 | }, { 313 | "id" : 37, 314 | "compiler" : "section", 315 | "input" : { 316 | "sessionId" : null, 317 | "code" : "USchema1", 318 | "extraFields" : { } 319 | } 320 | }, { 321 | "id" : 38, 322 | "compiler" : "markdown", 323 | "input" : { 324 | "sessionId" : null, 325 | "code" : "\n
\n", 326 | "extraFields" : { } 327 | } 328 | }, { 329 | "id" : 39, 330 | "compiler" : "section", 331 | "input" : { 332 | "sessionId" : null, 333 | "code" : "USchema2", 334 | "extraFields" : { } 335 | } 336 | }, { 337 | "id" : 40, 338 | "compiler" : "markdown", 339 | "input" : { 340 | "sessionId" : null, 341 | "code" : "\n
\n", 342 | "extraFields" : { } 343 | } 344 | }, { 345 | "id" : 41, 346 | "compiler" : "section", 347 | "input" : { 348 | "sessionId" : null, 349 | "code" : "USchema3", 350 | "extraFields" : { } 351 | } 352 | }, { 353 | "id" : 42, 354 | "compiler" : "markdown", 355 | "input" : { 356 | "sessionId" : null, 357 | "code" : "\n
\n", 358 | "extraFields" : { } 359 | } 360 | }, { 361 | "id" : 43, 362 | "compiler" : "section", 363 | "input" : { 364 | "sessionId" : null, 365 | "code" : "USchema4", 366 | "extraFields" : { } 367 | } 368 | }, { 369 | "id" : 44, 370 | "compiler" : "markdown", 371 | "input" : { 372 | "sessionId" : null, 373 | "code" : "\n
\n", 374 | "extraFields" : { } 375 | } 376 | }, { 377 | "id" : 45, 378 | "compiler" : "section", 379 | "input" : { 380 | "sessionId" : null, 381 | "code" : "USchema5", 382 | "extraFields" : { } 383 | } 384 | }, { 385 | "id" : 46, 386 | "compiler" : "markdown", 387 | "input" : { 388 | "sessionId" : null, 389 | "code" : "\n
\n", 390 | "extraFields" : { } 391 | } 392 | }, { 393 | "id" : 47, 394 | "compiler" : "section", 395 | "input" : { 396 | "sessionId" : null, 397 | "code" : "USchema6", 398 | "extraFields" : { } 399 | } 400 | }, { 401 | "id" : 48, 402 | "compiler" : "markdown", 403 | "input" : { 404 | "sessionId" : null, 405 | "code" : "\n
\n", 406 | "extraFields" : { } 407 | } 408 | }, { 409 | "id" : 49, 410 | "compiler" : "section", 411 | "input" : { 412 | "sessionId" : null, 413 | "code" : "USchema7", 414 | "extraFields" : { } 415 | } 416 | }, { 417 | "id" : 50, 418 | "compiler" : "markdown", 419 | "input" : { 420 | "sessionId" : null, 421 | "code" : "\n
\n", 422 | "extraFields" : { } 423 | } 424 | }, { 425 | "id" : 51, 426 | "compiler" : "section", 427 | "input" : { 428 | "sessionId" : null, 429 | "code" : "USchema8", 430 | "extraFields" : { } 431 | } 432 | }, { 433 | "id" : 52, 434 | "compiler" : "markdown", 435 | "input" : { 436 | "sessionId" : null, 437 | "code" : "\n
\n", 438 | "extraFields" : { } 439 | } 440 | }, { 441 | "id" : 53, 442 | "compiler" : "section", 443 | "input" : { 444 | "sessionId" : null, 445 | "code" : "USchema9", 446 | "extraFields" : { } 447 | } 448 | }, { 449 | "id" : 54, 450 | "compiler" : "markdown", 451 | "input" : { 452 | "sessionId" : null, 453 | "code" : "\n
\n", 454 | "extraFields" : { } 455 | } 456 | }, { 457 | "id" : 55, 458 | "compiler" : "section", 459 | "input" : { 460 | "sessionId" : null, 461 | "code" : "USchema10", 462 | "extraFields" : { } 463 | } 464 | }, { 465 | "id" : 56, 466 | "compiler" : "markdown", 467 | "input" : { 468 | "sessionId" : null, 469 | "code" : "\n
\n", 470 | "extraFields" : { } 471 | } 472 | }, { 473 | "id" : 57, 474 | "compiler" : "section", 475 | "input" : { 476 | "sessionId" : null, 477 | "code" : "USchema12", 478 | "extraFields" : { } 479 | } 480 | }, { 481 | "id" : 58, 482 | "compiler" : "markdown", 483 | "input" : { 484 | "sessionId" : null, 485 | "code" : "\n
\n", 486 | "extraFields" : { } 487 | } 488 | }, { 489 | "id" : 59, 490 | "compiler" : "section", 491 | "input" : { 492 | "sessionId" : null, 493 | "code" : "USchema13", 494 | "extraFields" : { } 495 | } 496 | }, { 497 | "id" : 60, 498 | "compiler" : "markdown", 499 | "input" : { 500 | "sessionId" : null, 501 | "code" : "\n
\n", 502 | "extraFields" : { } 503 | } 504 | }, { 505 | "id" : 61, 506 | "compiler" : "section", 507 | "input" : { 508 | "sessionId" : null, 509 | "code" : "USchema15", 510 | "extraFields" : { } 511 | } 512 | }, { 513 | "id" : 62, 514 | "compiler" : "markdown", 515 | "input" : { 516 | "sessionId" : null, 517 | "code" : "\n
\n", 518 | "extraFields" : { } 519 | } 520 | }, { 521 | "id" : 63, 522 | "compiler" : "section", 523 | "input" : { 524 | "sessionId" : null, 525 | "code" : "Results", 526 | "extraFields" : { } 527 | } 528 | }, { 529 | "id" : 64, 530 | "compiler" : "markdown", 531 | "input" : { 532 | "sessionId" : null, 533 | "code" : "### Results\n(Riedel et al, 2013)\n\n", 534 | "extraFields" : { } 535 | } 536 | } ], 537 | "config" : { } 538 | } 539 | -------------------------------------------------------------------------------- /src/main/moro/05_knowledge.json: -------------------------------------------------------------------------------- 1 | { 2 | "name" : "Inclusion of Prior Knowledge in Factorization Models", 3 | "cells" : [ { 4 | "id" : 0, 5 | "compiler" : "section", 6 | "input" : { 7 | "sessionId" : null, 8 | "code" : "drawbacks", 9 | "extraFields" : { } 10 | } 11 | }, { 12 | "id" : 1, 13 | "compiler" : "markdown", 14 | "input" : { 15 | "sessionId" : null, 16 | "code" : "### Drawbacks of OpenIE and Embeddings\n\n", 17 | "extraFields" : { } 18 | } 19 | }, { 20 | "id" : 2, 21 | "compiler" : "section", 22 | "input" : { 23 | "sessionId" : null, 24 | "code" : "drawbacks2", 25 | "extraFields" : { } 26 | } 27 | }, { 28 | "id" : 3, 29 | "compiler" : "markdown", 30 | "input" : { 31 | "sessionId" : null, 32 | "code" : "### Drawbacks of OpenIE and Embeddings\n\n", 33 | "extraFields" : { } 34 | } 35 | }, { 36 | "id" : 4, 37 | "compiler" : "section", 38 | "input" : { 39 | "sessionId" : null, 40 | "code" : "drawbacks3", 41 | "extraFields" : { } 42 | } 43 | }, { 44 | "id" : 5, 45 | "compiler" : "markdown", 46 | "input" : { 47 | "sessionId" : null, 48 | "code" : "### Drawbacks of OpenIE and Embeddings\n\n", 49 | "extraFields" : { } 50 | } 51 | }, { 52 | "id" : 6, 53 | "compiler" : "section", 54 | "input" : { 55 | "sessionId" : null, 56 | "code" : "drawbacks4", 57 | "extraFields" : { } 58 | } 59 | }, { 60 | "id" : 7, 61 | "compiler" : "markdown", 62 | "input" : { 63 | "sessionId" : null, 64 | "code" : "### Drawbacks of OpenIE and Embeddings\n\n", 65 | "extraFields" : { } 66 | } 67 | }, { 68 | "id" : 8, 69 | "compiler" : "section", 70 | "input" : { 71 | "sessionId" : null, 72 | "code" : "drawbacks5", 73 | "extraFields" : { } 74 | } 75 | }, { 76 | "id" : 9, 77 | "compiler" : "markdown", 78 | "input" : { 79 | "sessionId" : null, 80 | "code" : "### Drawbacks of OpenIE and Embeddings\n\n", 81 | "extraFields" : { } 82 | } 83 | }, { 84 | "id" : 10, 85 | "compiler" : "section", 86 | "input" : { 87 | "sessionId" : null, 88 | "code" : "facts", 89 | "extraFields" : { } 90 | } 91 | }, { 92 | "id" : 11, 93 | "compiler" : "markdown", 94 | "input" : { 95 | "sessionId" : null, 96 | "code" : "

Factual Prior Knowledge

\n\n\n\n- Collective Matrix Factoriztion (Section 7)\n- Discriminative Factorial Models (Section 6)", 97 | "extraFields" : { } 98 | } 99 | }, { 100 | "id" : 12, 101 | "compiler" : "section", 102 | "input" : { 103 | "sessionId" : null, 104 | "code" : "hard", 105 | "extraFields" : { } 106 | } 107 | }, { 108 | "id" : 13, 109 | "compiler" : "markdown", 110 | "input" : { 111 | "sessionId" : null, 112 | "code" : "

Hard Constraints

\n(e.g. Chang et al. 2014)\n\n", 113 | "extraFields" : { } 114 | } 115 | }, { 116 | "id" : 14, 117 | "compiler" : "section", 118 | "input" : { 119 | "sessionId" : null, 120 | "code" : "logic", 121 | "extraFields" : { } 122 | } 123 | }, { 124 | "id" : 15, 125 | "compiler" : "markdown", 126 | "input" : { 127 | "sessionId" : null, 128 | "code" : "

First-order Logic Prior Knowledge

\n", 129 | "extraFields" : { } 130 | } 131 | }, { 132 | "id" : 16, 133 | "compiler" : "section", 134 | "input" : { 135 | "sessionId" : null, 136 | "code" : "overview", 137 | "extraFields" : { } 138 | } 139 | }, { 140 | "id" : 17, 141 | "compiler" : "markdown", 142 | "input" : { 143 | "sessionId" : null, 144 | "code" : "### Low-rank Logic Embeddings \n\n", 145 | "extraFields" : { } 146 | } 147 | }, { 148 | "id" : 18, 149 | "compiler" : "section", 150 | "input" : { 151 | "sessionId" : null, 152 | "code" : "mflogic0", 153 | "extraFields" : { } 154 | } 155 | }, { 156 | "id" : 19, 157 | "compiler" : "markdown", 158 | "input" : { 159 | "sessionId" : null, 160 | "code" : "### Combining Logic and Matrix Factorization\n\n", 161 | "extraFields" : { } 162 | } 163 | }, { 164 | "id" : 20, 165 | "compiler" : "section", 166 | "input" : { 167 | "sessionId" : null, 168 | "code" : "mflogic1", 169 | "extraFields" : { } 170 | } 171 | }, { 172 | "id" : 21, 173 | "compiler" : "markdown", 174 | "input" : { 175 | "sessionId" : null, 176 | "code" : "### Combining Logic and Matrix Factorization\n\n", 177 | "extraFields" : { } 178 | } 179 | }, { 180 | "id" : 22, 181 | "compiler" : "section", 182 | "input" : { 183 | "sessionId" : null, 184 | "code" : "mfLogic2", 185 | "extraFields" : { } 186 | } 187 | }, { 188 | "id" : 23, 189 | "compiler" : "markdown", 190 | "input" : { 191 | "sessionId" : null, 192 | "code" : "### Combining Logic and Matrix Factorization\n\n", 193 | "extraFields" : { } 194 | } 195 | }, { 196 | "id" : 24, 197 | "compiler" : "section", 198 | "input" : { 199 | "sessionId" : null, 200 | "code" : "mfLogic3", 201 | "extraFields" : { } 202 | } 203 | }, { 204 | "id" : 25, 205 | "compiler" : "markdown", 206 | "input" : { 207 | "sessionId" : null, 208 | "code" : "### Combining Logic and Matrix Factorization\n\n", 209 | "extraFields" : { } 210 | } 211 | }, { 212 | "id" : 26, 213 | "compiler" : "section", 214 | "input" : { 215 | "sessionId" : null, 216 | "code" : "mfLogic4", 217 | "extraFields" : { } 218 | } 219 | }, { 220 | "id" : 27, 221 | "compiler" : "markdown", 222 | "input" : { 223 | "sessionId" : null, 224 | "code" : "### Combining Logic and Matrix Factorization\n\n\n", 225 | "extraFields" : { } 226 | } 227 | }, { 228 | "id" : 28, 229 | "compiler" : "section", 230 | "input" : { 231 | "sessionId" : null, 232 | "code" : "mfLogic5", 233 | "extraFields" : { } 234 | } 235 | }, { 236 | "id" : 29, 237 | "compiler" : "markdown", 238 | "input" : { 239 | "sessionId" : null, 240 | "code" : "### Combining Logic and Matrix Factorization\n\n", 241 | "extraFields" : { } 242 | } 243 | }, { 244 | "id" : 30, 245 | "compiler" : "section", 246 | "input" : { 247 | "sessionId" : null, 248 | "code" : "mfLogic6", 249 | "extraFields" : { } 250 | } 251 | }, { 252 | "id" : 31, 253 | "compiler" : "markdown", 254 | "input" : { 255 | "sessionId" : null, 256 | "code" : "### Combining Logic and Matrix Factorization\n\n", 257 | "extraFields" : { } 258 | } 259 | }, { 260 | "id" : 32, 261 | "compiler" : "section", 262 | "input" : { 263 | "sessionId" : null, 264 | "code" : "mfLogic7", 265 | "extraFields" : { } 266 | } 267 | }, { 268 | "id" : 33, 269 | "compiler" : "markdown", 270 | "input" : { 271 | "sessionId" : null, 272 | "code" : "### Combining Logic and Matrix Factorization\n\n", 273 | "extraFields" : { } 274 | } 275 | }, { 276 | "id" : 34, 277 | "compiler" : "section", 278 | "input" : { 279 | "sessionId" : null, 280 | "code" : "mfLogic8", 281 | "extraFields" : { } 282 | } 283 | }, { 284 | "id" : 35, 285 | "compiler" : "markdown", 286 | "input" : { 287 | "sessionId" : null, 288 | "code" : "### Combining Logic and Matrix Factorization\n\n", 289 | "extraFields" : { } 290 | } 291 | }, { 292 | "id" : 36, 293 | "compiler" : "section", 294 | "input" : { 295 | "sessionId" : null, 296 | "code" : "mfLogic9", 297 | "extraFields" : { } 298 | } 299 | }, { 300 | "id" : 37, 301 | "compiler" : "markdown", 302 | "input" : { 303 | "sessionId" : null, 304 | "code" : "### Combining Logic and Matrix Factorization\n\n", 305 | "extraFields" : { } 306 | } 307 | }, { 308 | "id" : 38, 309 | "compiler" : "section", 310 | "input" : { 311 | "sessionId" : null, 312 | "code" : "mfLogic10", 313 | "extraFields" : { } 314 | } 315 | }, { 316 | "id" : 39, 317 | "compiler" : "markdown", 318 | "input" : { 319 | "sessionId" : null, 320 | "code" : "### Combining Logic and Matrix Factorization\n\n", 321 | "extraFields" : { } 322 | } 323 | }, { 324 | "id" : 40, 325 | "compiler" : "section", 326 | "input" : { 327 | "sessionId" : null, 328 | "code" : "mfLogic11", 329 | "extraFields" : { } 330 | } 331 | }, { 332 | "id" : 41, 333 | "compiler" : "markdown", 334 | "input" : { 335 | "sessionId" : null, 336 | "code" : "### Combining Logic and Matrix Factorization\n\n", 337 | "extraFields" : { } 338 | } 339 | }, { 340 | "id" : 42, 341 | "compiler" : "section", 342 | "input" : { 343 | "sessionId" : null, 344 | "code" : "mfLogic12", 345 | "extraFields" : { } 346 | } 347 | }, { 348 | "id" : 43, 349 | "compiler" : "markdown", 350 | "input" : { 351 | "sessionId" : null, 352 | "code" : "### Combining Logic and Matrix Factorization\n\n", 353 | "extraFields" : { } 354 | } 355 | }, { 356 | "id" : 44, 357 | "compiler" : "section", 358 | "input" : { 359 | "sessionId" : null, 360 | "code" : "mfLogic13", 361 | "extraFields" : { } 362 | } 363 | }, { 364 | "id" : 45, 365 | "compiler" : "markdown", 366 | "input" : { 367 | "sessionId" : null, 368 | "code" : "### Combining Logic and Matrix Factorization\n\n", 369 | "extraFields" : { } 370 | } 371 | }, { 372 | "id" : 46, 373 | "compiler" : "section", 374 | "input" : { 375 | "sessionId" : null, 376 | "code" : "mfLogic14", 377 | "extraFields" : { } 378 | } 379 | }, { 380 | "id" : 47, 381 | "compiler" : "markdown", 382 | "input" : { 383 | "sessionId" : null, 384 | "code" : "### Combining Logic and Matrix Factorization\n\n", 385 | "extraFields" : { } 386 | } 387 | }, { 388 | "id" : 48, 389 | "compiler" : "section", 390 | "input" : { 391 | "sessionId" : null, 392 | "code" : "injectfacts", 393 | "extraFields" : { } 394 | } 395 | }, { 396 | "id" : 49, 397 | "compiler" : "html", 398 | "input" : { 399 | "sessionId" : null, 400 | "code" : "

Matrix Factorization is “Injecting” Atomic Formulae

\n", 401 | "extraFields" : { } 402 | } 403 | }, { 404 | "id" : 50, 405 | "compiler" : "section", 406 | "input" : { 407 | "sessionId" : null, 408 | "code" : "difflogic", 409 | "extraFields" : { } 410 | } 411 | }, { 412 | "id" : 51, 413 | "compiler" : "html", 414 | "input" : { 415 | "sessionId" : null, 416 | "code" : "

Differentiable Logic Formulae

\n\n$$\n[\\mathcal{F}] = \\begin{cases}\n \\sigma(\\mathbf{v}_s \\cdot \\mathbf{v}_{ij}) & \\text{ if } \\mathcal{F} = r_s(e_i, e_j), \\text{ i.e., facts}\\newline\n 1 - [\\mathcal{A}] & \\text{ if } \\mathcal{F} = \\neg\\mathcal{A}\\newline\n [\\mathcal{A}] * [\\mathcal{B}] &\\text{ if } \\mathcal{F} = \\mathcal{A} \\wedge \\mathcal{B}\n\\end{cases}\n$$\n\n", 417 | "extraFields" : { } 418 | } 419 | }, { 420 | "id" : 52, 421 | "compiler" : "section", 422 | "input" : { 423 | "sessionId" : null, 424 | "code" : "grounding", 425 | "extraFields" : { } 426 | } 427 | }, { 428 | "id" : 53, 429 | "compiler" : "html", 430 | "input" : { 431 | "sessionId" : null, 432 | "code" : "

Grounding

\n$$\\forall x,y: r_s(x,y) \\Rightarrow r_t(x,y)$$\n", 433 | "extraFields" : { } 434 | } 435 | }, { 436 | "id" : 54, 437 | "compiler" : "section", 438 | "input" : { 439 | "sessionId" : null, 440 | "code" : "results1", 441 | "extraFields" : { } 442 | } 443 | }, { 444 | "id" : 55, 445 | "compiler" : "markdown", 446 | "input" : { 447 | "sessionId" : null, 448 | "code" : "### Zero-shot Relation Learning\n\n", 449 | "extraFields" : { } 450 | } 451 | }, { 452 | "id" : 56, 453 | "compiler" : "section", 454 | "input" : { 455 | "sessionId" : null, 456 | "code" : "results2", 457 | "extraFields" : { } 458 | } 459 | }, { 460 | "id" : 57, 461 | "compiler" : "markdown", 462 | "input" : { 463 | "sessionId" : null, 464 | "code" : "### Zero-shot Relation Learning\n\n", 465 | "extraFields" : { } 466 | } 467 | }, { 468 | "id" : 58, 469 | "compiler" : "section", 470 | "input" : { 471 | "sessionId" : null, 472 | "code" : "results3", 473 | "extraFields" : { } 474 | } 475 | }, { 476 | "id" : 59, 477 | "compiler" : "markdown", 478 | "input" : { 479 | "sessionId" : null, 480 | "code" : "### Zero-shot Relation Learning\n\n", 481 | "extraFields" : { } 482 | } 483 | }, { 484 | "id" : 60, 485 | "compiler" : "section", 486 | "input" : { 487 | "sessionId" : null, 488 | "code" : "results4", 489 | "extraFields" : { } 490 | } 491 | }, { 492 | "id" : 61, 493 | "compiler" : "markdown", 494 | "input" : { 495 | "sessionId" : null, 496 | "code" : "### Zero-shot Relation Learning\n\n", 497 | "extraFields" : { } 498 | } 499 | }, { 500 | "id" : 62, 501 | "compiler" : "section", 502 | "input" : { 503 | "sessionId" : null, 504 | "code" : "results5", 505 | "extraFields" : { } 506 | } 507 | }, { 508 | "id" : 63, 509 | "compiler" : "markdown", 510 | "input" : { 511 | "sessionId" : null, 512 | "code" : "### Zero-shot Relation Learning\n\n", 513 | "extraFields" : { } 514 | } 515 | }, { 516 | "id" : 64, 517 | "compiler" : "section", 518 | "input" : { 519 | "sessionId" : null, 520 | "code" : "results", 521 | "extraFields" : { } 522 | } 523 | }, { 524 | "id" : 65, 525 | "compiler" : "markdown", 526 | "input" : { 527 | "sessionId" : null, 528 | "code" : "### Full Dataset\n\n", 529 | "extraFields" : { } 530 | } 531 | } ], 532 | "config" : { } 533 | } 534 | -------------------------------------------------------------------------------- /src/main/moro/06_tf.json: -------------------------------------------------------------------------------- 1 | { 2 | "name" : "Tensor Factorization", 3 | "cells" : [ { 4 | "id" : 44, 5 | "compiler" : "section", 6 | "input" : { 7 | "sessionId" : null, 8 | "code" : "homer", 9 | "extraFields" : { } 10 | } 11 | }, { 12 | "id" : 45, 13 | "compiler" : "markdown", 14 | "input" : { 15 | "sessionId" : null, 16 | "code" : "", 17 | "extraFields" : { } 18 | } 19 | }, { 20 | "id" : 0, 21 | "compiler" : "section", 22 | "input" : { 23 | "sessionId" : null, 24 | "code" : "tensor", 25 | "extraFields" : { } 26 | } 27 | }, { 28 | "id" : 1, 29 | "compiler" : "markdown", 30 | "input" : { 31 | "sessionId" : null, 32 | "code" : "

Tensors

\n", 33 | "extraFields" : { } 34 | } 35 | }, { 36 | "id" : 2, 37 | "compiler" : "section", 38 | "input" : { 39 | "sessionId" : null, 40 | "code" : "notation", 41 | "extraFields" : { } 42 | } 43 | }, { 44 | "id" : 3, 45 | "compiler" : "html", 46 | "input" : { 47 | "sessionId" : null, 48 | "code" : "

Notation

\n(Kolda and Bader, 2009)\n\n", 49 | "extraFields" : { } 50 | } 51 | }, { 52 | "id" : 4, 53 | "compiler" : "section", 54 | "input" : { 55 | "sessionId" : null, 56 | "code" : "example", 57 | "extraFields" : { } 58 | } 59 | }, { 60 | "id" : 5, 61 | "compiler" : "markdown", 62 | "input" : { 63 | "sessionId" : null, 64 | "code" : "\n### Example Order-3 Tensor\n- \\\\(\\mathcal{T} \\in \\mathbb{R}^{|E| \\,\\times\\, |E| \\,\\times\\, |R|}\\\\)\n\n", 65 | "extraFields" : { } 66 | } 67 | }, { 68 | "id" : 6, 69 | "compiler" : "section", 70 | "input" : { 71 | "sessionId" : null, 72 | "code" : "fibers", 73 | "extraFields" : { } 74 | } 75 | }, { 76 | "id" : 7, 77 | "compiler" : "markdown", 78 | "input" : { 79 | "sessionId" : null, 80 | "code" : "### Order-3 Tensor Fibers\n\n\n\n- \\\\(\\mathbf{t}_{\\cdot jk}\\\\) is used to denote the mode-1 **column fiber** when fixing mode 2 to j and mode 3 to k\n- \\\\(\\mathbf{t}_{i \\cdot k}\\\\) mode-2 **row fiber**\n- \\\\(\\mathbf{t}_{ij \\cdot}\\\\) mode-3 **tube fiber**", 81 | "extraFields" : { } 82 | } 83 | }, { 84 | "id" : 8, 85 | "compiler" : "section", 86 | "input" : { 87 | "sessionId" : null, 88 | "code" : "slices", 89 | "extraFields" : { } 90 | } 91 | }, { 92 | "id" : 9, 93 | "compiler" : "markdown", 94 | "input" : { 95 | "sessionId" : null, 96 | "code" : "### Order-3 Tensor Slices\n\n\n\n- \\\\(\\mathbf{T}_{i\\cdot\\cdot}\\\\) denotes the **horizontal slice** when fixing the mode-1 index to i\n- \\\\(\\mathbf{T}_{\\cdot j \\cdot}\\\\) **vertical slice**\n- \\\\(\\mathbf{T}_{\\cdot\\cdot k}\\\\) **lateral slice**", 97 | "extraFields" : { } 98 | } 99 | }, { 100 | "id" : 10, 101 | "compiler" : "section", 102 | "input" : { 103 | "sessionId" : null, 104 | "code" : "algebra", 105 | "extraFields" : { } 106 | } 107 | }, { 108 | "id" : 11, 109 | "compiler" : "markdown", 110 | "input" : { 111 | "sessionId" : null, 112 | "code" : "### Tensor Operations\n- Mode-\\\\(N\\\\) **tensor-vector product** \\\\(\\mathcal{T} \\times_N \\mathbf{v}\\\\)\n - Dot product of each mode-\\\\(N\\\\) fiber in \\\\(\\mathcal{T}\\\\) with \\\\(\\mathbf{v}\\\\)\n - \\\\(\\mathcal{T} \\in \\mathbb{R}^{I_1\\,\\times\\,\\cdots\\,\\times\\,I_N\\,\\times\\,\\cdots\\,I_n} \\\\)\n - \\\\(\\mathbf{v} \\in \\mathbb{R}^{I_N}\\\\)\n - \\\\(\\mathcal{T} \\times_N \\mathbf{v} \\in \\mathbb{R}^{I_1\\,\\times\\,\\cdots\\,\\times\\,I_{N-1}\\,\\times\\,I_{N+1}\\,\\times\\,\\cdots\\,I_n} \\\\)\n - Resulting tensor has \\\\(N-1\\\\) modes\n\n\n\n", 113 | "extraFields" : { } 114 | } 115 | }, { 116 | "id" : 12, 117 | "compiler" : "section", 118 | "input" : { 119 | "sessionId" : null, 120 | "code" : "algebra2", 121 | "extraFields" : { } 122 | } 123 | }, { 124 | "id" : 13, 125 | "compiler" : "markdown", 126 | "input" : { 127 | "sessionId" : null, 128 | "code" : "### Tensor Operations\n- Mode-\\\\(N\\\\) **tensor-matrix product** \\\\(\\mathcal{T} \\times_N \\mathbf{M}\\\\)\n - Matrix-vector product of each mode-\\\\(N\\\\) fiber in \\\\(\\mathcal{T}\\\\) with \\\\(\\mathbf{M}\\\\)\n - \\\\(\\mathcal{T} \\in \\mathbb{R}^{I_1\\,\\times\\,\\cdots\\,\\times\\,I_N\\,\\times\\,\\cdots\\,I_n} \\\\)\n - \\\\(\\mathbf{M}\\in\\mathbb{R}^{K \\,\\times\\, I_N}\\\\)\n - \\\\(\\mathcal{T} \\times_N \\mathbf{M} \\in \\mathbb{R}^{I_1\\,\\times\\,\\cdots\\,\\times\\,K\\,\\times\\,\\cdots\\,I_n} \\\\)\n\n\n", 129 | "extraFields" : { } 130 | } 131 | }, { 132 | "id" : 14, 133 | "compiler" : "section", 134 | "input" : { 135 | "sessionId" : null, 136 | "code" : "algebra3", 137 | "extraFields" : { } 138 | } 139 | }, { 140 | "id" : 15, 141 | "compiler" : "markdown", 142 | "input" : { 143 | "sessionId" : null, 144 | "code" : "### Tensor Operations\n- Mode-\\\\(N\\\\) **matricization** \\\\(\\mathbf{T}_{(N)}\\\\)\n - Arrange all mode-\\\\(N\\\\) fibers as columns\n\n \n", 145 | "extraFields" : { } 146 | } 147 | }, { 148 | "id" : 16, 149 | "compiler" : "section", 150 | "input" : { 151 | "sessionId" : null, 152 | "code" : "tensorrank", 153 | "extraFields" : { } 154 | } 155 | }, { 156 | "id" : 17, 157 | "compiler" : "markdown", 158 | "input" : { 159 | "sessionId" : null, 160 | "code" : "### Tensor Rank\n\n- **Rank-\\\\(1\\\\) tensor**: outer product of three vectors:\n\n \\\\(\\mathcal{X} = \\mathbf{a} \\otimes \\mathbf{b} \\otimes \\mathbf{c}\\\\) \n\n \n\n- Rank of a tensor \\\\(\\mathcal{T}\\\\): smallest number of rank-\\\\(1\\\\) tensor that add up to \\\\(\\mathcal{T}\\\\)", 161 | "extraFields" : { } 162 | } 163 | }, { 164 | "id" : 18, 165 | "compiler" : "section", 166 | "input" : { 167 | "sessionId" : null, 168 | "code" : "tucker", 169 | "extraFields" : { } 170 | } 171 | }, { 172 | "id" : 19, 173 | "compiler" : "html", 174 | "input" : { 175 | "sessionId" : null, 176 | "code" : "

Tucker Decomposition

\n(Tucker, 1966)\n", 177 | "extraFields" : { } 178 | } 179 | }, { 180 | "id" : 20, 181 | "compiler" : "section", 182 | "input" : { 183 | "sessionId" : null, 184 | "code" : "tucker3example", 185 | "extraFields" : { } 186 | } 187 | }, { 188 | "id" : 21, 189 | "compiler" : "markdown", 190 | "input" : { 191 | "sessionId" : null, 192 | "code" : "### Example\n\n- \\\\(\\mathcal{T} \\approx \\mathcal{G} \\times_1 \\mathbf{R} \\times_2 \\mathbf{E_1} \\times_3 \\mathbf{E}_2\\\\)\n - \\\\(\\mathcal{T} \\in \\mathbb{R}^{|R| \\,\\times\\, |E| \\,\\times\\, |E|}, \\mathcal{G} \\in \\mathbb{R}^{k \\,\\times\\, k \\,\\times\\, k}\\\\)\n - \\\\(\\mathbf{R} \\in \\mathbb{R}^{|R| \\,\\times\\, k}, \\mathbf{E}_1 \\in \\mathbb{R}^{|E| \\,\\times\\, k}, \\mathbf{E}_2 \\in \\mathbb{E}^{|R| \\,\\times\\, k}\\\\)\n\n\n\n", 193 | "extraFields" : { } 194 | } 195 | }, { 196 | "id" : 22, 197 | "compiler" : "section", 198 | "input" : { 199 | "sessionId" : null, 200 | "code" : "tucker2", 201 | "extraFields" : { } 202 | } 203 | }, { 204 | "id" : 23, 205 | "compiler" : "markdown", 206 | "input" : { 207 | "sessionId" : null, 208 | "code" : "### Tucker2 Decomposition\n\n\n\n", 209 | "extraFields" : { } 210 | } 211 | }, { 212 | "id" : 24, 213 | "compiler" : "section", 214 | "input" : { 215 | "sessionId" : null, 216 | "code" : "tucker1", 217 | "extraFields" : { } 218 | } 219 | }, { 220 | "id" : 25, 221 | "compiler" : "markdown", 222 | "input" : { 223 | "sessionId" : null, 224 | "code" : "### Matrix Factorization as Tucker1 Decomposition\n\n- **Tucker1** factorizes only along one mode\n- Is an instance of matrix factorization\n - Learns vectors for pairs of variables of two modes\n - Two of the loading matrices are the identity\n - For instance: \\\\(\\mathcal{T} \\approx \\mathcal{G} \\times_1 \\mathit{I} \\times_2 \\mathit{I} \\times_3 \\mathbf{C}\\\\)\n- Example:\n\n\n", 225 | "extraFields" : { } 226 | } 227 | }, { 228 | "id" : 26, 229 | "compiler" : "section", 230 | "input" : { 231 | "sessionId" : null, 232 | "code" : "candecomp", 233 | "extraFields" : { } 234 | } 235 | }, { 236 | "id" : 27, 237 | "compiler" : "markdown", 238 | "input" : { 239 | "sessionId" : null, 240 | "code" : "### CANDECOMP/PARAFAC\n(Carroll and Chang, 1970; Harshman, 1970)\n\n- Approximate \\\\(\\mathcal{T}\\\\) with a sum of \\\\(n\\\\) rank-\\\\(1\\\\) tensors\n\n \\\\(\\mathcal{T} \\approx \\sum_{i=1}^n \\mathbf{a}_i \\otimes \\mathbf{b}_i \\otimes \\mathbf{c}_i\\\\)\n \n- Loss\n\n \\\\(\\min_{\\mathbf{a}_i\\mathbf{b}_i\\mathbf{c}_i} ||\\mathcal{T} - \\sum_{i=1}^n \\mathbf{a}_i \\otimes \\mathbf{b}_i \\otimes \\mathbf{c}_i||_F^2\\\\)", 241 | "extraFields" : { } 242 | } 243 | }, { 244 | "id" : 28, 245 | "compiler" : "section", 246 | "input" : { 247 | "sessionId" : null, 248 | "code" : "rescal", 249 | "extraFields" : { } 250 | } 251 | }, { 252 | "id" : 29, 253 | "compiler" : "markdown", 254 | "input" : { 255 | "sessionId" : null, 256 | "code" : "### RESCAL\n(Nickel et al, 2011; 2012)\n
\n\n\n\n", 257 | "extraFields" : { } 258 | } 259 | }, { 260 | "id" : 30, 261 | "compiler" : "section", 262 | "input" : { 263 | "sessionId" : null, 264 | "code" : "rescal2", 265 | "extraFields" : { } 266 | } 267 | }, { 268 | "id" : 31, 269 | "compiler" : "markdown", 270 | "input" : { 271 | "sessionId" : null, 272 | "code" : "### RESCAL\n(Nickel et al, 2011; 2012)\n\n", 273 | "extraFields" : { } 274 | } 275 | }, { 276 | "id" : 32, 277 | "compiler" : "section", 278 | "input" : { 279 | "sessionId" : null, 280 | "code" : "results", 281 | "extraFields" : { } 282 | } 283 | }, { 284 | "id" : 33, 285 | "compiler" : "markdown", 286 | "input" : { 287 | "sessionId" : null, 288 | "code" : "### Results \n\n\n\n", 289 | "extraFields" : { } 290 | } 291 | }, { 292 | "id" : 34, 293 | "compiler" : "section", 294 | "input" : { 295 | "sessionId" : null, 296 | "code" : "van", 297 | "extraFields" : { } 298 | } 299 | }, { 300 | "id" : 35, 301 | "compiler" : "markdown", 302 | "input" : { 303 | "sessionId" : null, 304 | "code" : "### Factorization Model of Semantic Compositionality\n(Van de Cruys et al, 2013)\n\n
\n\n\n\n", 305 | "extraFields" : { } 306 | } 307 | }, { 308 | "id" : 36, 309 | "compiler" : "section", 310 | "input" : { 311 | "sessionId" : null, 312 | "code" : "van2", 313 | "extraFields" : { } 314 | } 315 | }, { 316 | "id" : 37, 317 | "compiler" : "markdown", 318 | "input" : { 319 | "sessionId" : null, 320 | "code" : "### Factorization Model of Semantic Compositionality\n(Van de Cruys et al, 2013)\n\n- Captures three-way interaction of subject, verb, object triplets\n- Instance of Tucker2 decomposition\n - \\\\(\\mathcal{T} \\approx \\mathcal{V} \\times_1 \\mathbf{N} \\times_2 \\mathbf{N}\\\\)\n - \\\\(\\mathbf{N} \\in \\mathbb{R}^{|N| \\,\\times\\, k}\\\\) is the dictionary matrix of noun embeddings\n - \\\\(\\mathcal{V}\\\\) holds slice \\\\(\\mathbf{V}_s\\in \\mathbb{R}^{k \\,\\times\\, k}\\\\) for each verb \\\\(s\\\\)\n", 321 | "extraFields" : { } 322 | } 323 | }, { 324 | "id" : 38, 325 | "compiler" : "section", 326 | "input" : { 327 | "sessionId" : null, 328 | "code" : "nn", 329 | "extraFields" : { } 330 | } 331 | }, { 332 | "id" : 39, 333 | "compiler" : "markdown", 334 | "input" : { 335 | "sessionId" : null, 336 | "code" : "### Relationship to Neural Networks\nMatrix Factorization: \\\\(\\mathbf{T} \\approx \\sigma(\\mathbf{W}^t_p\\mathbf{W}_r)\\\\)\n\n\n", 337 | "extraFields" : { } 338 | } 339 | }, { 340 | "id" : 40, 341 | "compiler" : "section", 342 | "input" : { 343 | "sessionId" : null, 344 | "code" : "nn2", 345 | "extraFields" : { } 346 | } 347 | }, { 348 | "id" : 41, 349 | "compiler" : "markdown", 350 | "input" : { 351 | "sessionId" : null, 352 | "code" : "### Relationship to Neural Networks\n(Nickel, 2015)\n\nRESCAL: \\\\(\\mathcal{T} \\approx \\mathcal{R} \\times_1 \\mathbf{A} \\times_2 \\mathbf{A}\\\\)\n\n\n\n", 353 | "extraFields" : { } 354 | } 355 | }, { 356 | "id" : 42, 357 | "compiler" : "section", 358 | "input" : { 359 | "sessionId" : null, 360 | "code" : "nn3", 361 | "extraFields" : { } 362 | } 363 | }, { 364 | "id" : 43, 365 | "compiler" : "markdown", 366 | "input" : { 367 | "sessionId" : null, 368 | "code" : "### Combining Matrix and Tensor Factorization\n(e.g. Chang et al. 2014, Singh et al. 2015)\n\n", 369 | "extraFields" : { } 370 | } 371 | } ], 372 | "config" : { } 373 | } 374 | -------------------------------------------------------------------------------- /src/main/moro/08_prediction.json: -------------------------------------------------------------------------------- 1 | { 2 | "name" : "Discriminative Factorial Models", 3 | "cells" : [ { 4 | "id" : 0, 5 | "compiler" : "section", 6 | "input" : { 7 | "sessionId" : null, 8 | "code" : "IntroToDiscriminativeFactorialModels", 9 | "extraFields" : { } 10 | } 11 | }, { 12 | "id" : 1, 13 | "compiler" : "markdown", 14 | "input" : { 15 | "sessionId" : null, 16 | "code" : "### Discriminative Factorial Models\n\nFactorization is an efficient way of reducing the effective number of parameters in discriminative/predictive models\n\nWe introduce:\n\n* Factorization Machines\n* Multi-Task/Multi-Label Learning with Matrix Factorization\n* Structured Prediction with Factorized Parameters", 17 | "extraFields" : { } 18 | } 19 | }, { 20 | "id" : 2, 21 | "compiler" : "section", 22 | "input" : { 23 | "sessionId" : null, 24 | "code" : "fm", 25 | "extraFields" : { } 26 | } 27 | }, { 28 | "id" : 3, 29 | "compiler" : "markdown", 30 | "input" : { 31 | "sessionId" : null, 32 | "code" : "### Factorization Machines\n\nBinary Matrix Factorization as a Logistic Regression\nMatrix \\\\( Y\\in\\Re^{n,d} \\\\). For any \\\\(K\\\\):\n\n\\\\( P(\\mathbf{Y}_{ij}=1|i,j) = \\sigma(\\langle \\mathbf{U}_{i:}, \\mathbf{V}_{j:}\\rangle) \\\\) where \\\\(\\mathbf{U}\\in\\Re^{N\\times K}\\\\) and \\\\(\\mathbf{V}\\in\\Re^{M\\times K}\\\\)\n\n", 33 | "extraFields" : { } 34 | } 35 | }, { 36 | "id" : 4, 37 | "compiler" : "markdown", 38 | "input" : { 39 | "sessionId" : null, 40 | "code" : "Is equivalent to:\n\n\\\\( P(y_{t}=1|x_t = (i,j) ) = \\sigma(\\langle\\mathbf{\\Theta}, \\Phi(x_t)\\rangle) \\\\) \n\nu.c. rank(\\\\(\\mathbf{\\Theta}\\\\)) = *K*\n\n- \\\\(\\Phi(x_t) = \\mathbf{e}_i \\otimes \\mathbf{e}_j\\\\) : standard MF\n- \\\\(\\Phi(x_t) = [1;\\mathbf{e}_i] \\otimes [1;\\mathbf{e}_j]\\\\) : MF with row and columns bias\n\n\\\\( \\rightarrow \\\\) called **factorization machine** [Rendle 2010]", 41 | "extraFields" : { 42 | "fragment" : "true" 43 | } 44 | } 45 | }, { 46 | "id" : 5, 47 | "compiler" : "section", 48 | "input" : { 49 | "sessionId" : null, 50 | "code" : "rrr", 51 | "extraFields" : { } 52 | } 53 | }, { 54 | "id" : 6, 55 | "compiler" : "markdown", 56 | "input" : { 57 | "sessionId" : null, 58 | "code" : "### Reduced Rank Regression\n\nMultiple Linear Regression:\n\n- *d* Inputs: \\\\(\\mathbf{X}\\in\\Re^{n \\times d}\\\\)\n- *K* Outputs: Matrix \\\\( \\mathbf{Y}\\in\\Re^{n \\times K} \\\\)\n\nLinear regression:\n\n\n\\\\( \\mathrm{min}\\ \\sum_{k=1}^K \\sum_{i=1}^n (y_{ik} - x_{i:}^T \\theta_k)^2 = ||\\mathbf{Y}-\\mathbf{X} \\mathbf{\\Theta} ||^2_F\\\\)\n\n- Parameters: Matrix \\\\( \\mathbf{Y}\\in\\Re^{n \\times K} \\\\)\n\n\n**Reduced Rank Regression** assumes \\\\( \\mathbf{\\Theta} = \\mathbf{U} \\mathbf{V}^T \\\\)\n", 59 | "extraFields" : { } 60 | } 61 | }, { 62 | "id" : 7, 63 | "compiler" : "section", 64 | "input" : { 65 | "sessionId" : null, 66 | "code" : "multitask", 67 | "extraFields" : { } 68 | } 69 | }, { 70 | "id" : 8, 71 | "compiler" : "markdown", 72 | "input" : { 73 | "sessionId" : null, 74 | "code" : "### Multi-Task Learning\n* Inputs: \\\\(d\\\\) feature \\\\(\\mathbf\\phi(x_i)\\in\\Re^d\\\\)\n* Outputs: \\\\(K\\\\) labels \\\\(\\mathbf{y}_i\\in\\lbrace 0,1 \\rbrace^K\\\\)\n\n\\\\( P(\\mathbf{y}_{i}|x_i) = \\prod_{k=1}^K \\mathbf{\\sigma}(\\mathbf\\phi(x_i) \\mathbf{U} \\mathbf{v}_{k:}^T) \\\\)\n\nCan be interpreted as label embedding: \\\\(\\mathbf{v}_{k:}\\\\) is the \\\\(R\\\\)-dimensional embedding of the \\\\(k\\\\)-th label.\n", 75 | "extraFields" : { } 76 | } 77 | }, { 78 | "id" : 9, 79 | "compiler" : "section", 80 | "input" : { 81 | "sessionId" : null, 82 | "code" : "SP", 83 | "extraFields" : { } 84 | } 85 | }, { 86 | "id" : 10, 87 | "compiler" : "markdown", 88 | "input" : { 89 | "sessionId" : null, 90 | "code" : "### Structured Prediction\n\nGoal: Predict \\\\(y^* = \\arg\\max_{y\\in T(\\mathbf{x})} S(\\mathbf{x},\\mathbf{y};\\mathbf{\\Theta})\\\\)\n\n- \\\\(\\mathbf{y}\\\\) is a structured output\n\n- \\\\(S(\\mathbf{x},\\mathbf{y};\\mathbf{\\Theta}) = <\\mathbf{\\Phi}(\\mathbf{x},\\mathbf{y}), \\mathbf{\\Theta}>\\\\) is a score function\n\n- \\\\(T(\\mathbf{x})\\\\) is all possible structures\n\nIn NLP \\\\(\\mathbf{\\Theta}\\\\) is often a vector, but it can be a matrix or tensor.", 91 | "extraFields" : { } 92 | } 93 | }, { 94 | "id" : 11, 95 | "compiler" : "section", 96 | "input" : { 97 | "sessionId" : null, 98 | "code" : "SPex", 99 | "extraFields" : { } 100 | } 101 | }, { 102 | "id" : 12, 103 | "compiler" : "markdown", 104 | "input" : { 105 | "sessionId" : null, 106 | "code" : "### Examples of NLP Structured Prediction\n\nLei et al.: Low-Rank Tensors for Scoring Dependency (ACL 2014)\n\n
\n", 107 | "extraFields" : { } 108 | } 109 | }, { 110 | "id" : 13, 111 | "compiler" : "section", 112 | "input" : { 113 | "sessionId" : null, 114 | "code" : "concatex", 115 | "extraFields" : { } 116 | } 117 | }, { 118 | "id" : 14, 119 | "compiler" : "markdown", 120 | "input" : { 121 | "sessionId" : null, 122 | "code" : "### Standard Vector Features\n\n
\n", 123 | "extraFields" : { } 124 | } 125 | }, { 126 | "id" : 15, 127 | "compiler" : "section", 128 | "input" : { 129 | "sessionId" : null, 130 | "code" : "concatex2", 131 | "extraFields" : { } 132 | } 133 | }, { 134 | "id" : 16, 135 | "compiler" : "markdown", 136 | "input" : { 137 | "sessionId" : null, 138 | "code" : "### High Order Features\n\n
\n", 139 | "extraFields" : { } 140 | } 141 | }, { 142 | "id" : 17, 143 | "compiler" : "section", 144 | "input" : { 145 | "sessionId" : null, 146 | "code" : "concatex3", 147 | "extraFields" : { } 148 | } 149 | }, { 150 | "id" : 18, 151 | "compiler" : "markdown", 152 | "input" : { 153 | "sessionId" : null, 154 | "code" : "### Difficulties of Manual Feature Selection\nFew Templates:\n\n- Poor Performance\n\nMany Templates:\n\n- High Performance \\\\(\\implies\\\\) Many Parameters\n- Useful feature interactions hard to know a priori\n", 155 | "extraFields" : { } 156 | } 157 | }, { 158 | "id" : 19, 159 | "compiler" : "markdown", 160 | "input" : { 161 | "sessionId" : null, 162 | "code" : "Alternatives? Automatic Feature Selection:\n\n- Effective, but ''messy'' (Zhao, 2009)\n- Computationally expensive", 163 | "extraFields" : { 164 | "fragment" : "true" 165 | } 166 | } 167 | }, { 168 | "id" : 20, 169 | "compiler" : "markdown", 170 | "input" : { 171 | "sessionId" : null, 172 | "code" : "\n**Solution**: Learn templates from data using matrix factorization", 173 | "extraFields" : { 174 | "fragment" : "true" 175 | } 176 | } 177 | }, { 178 | "id" : 21, 179 | "compiler" : "section", 180 | "input" : { 181 | "sessionId" : null, 182 | "code" : "pstep1", 183 | "extraFields" : { } 184 | } 185 | }, { 186 | "id" : 22, 187 | "compiler" : "markdown", 188 | "input" : { 189 | "sessionId" : null, 190 | "code" : "### Step 1: Identify Simple Features\n\nFeature vectors for each type of information: \n\n - \\\\(\\phi_{head}\\\\), vector \\\\(\\in \\Re^n\\\\) for head token\n - \\\\(\\phi_{child}\\\\), vector \\\\(\\in \\Re^n\\\\)for child token\n - \\\\(\\phi_{arc}\\\\), vector \\\\(\\in \\Re^n\\\\) for arc information\n\n\n", 191 | "extraFields" : { } 192 | } 193 | }, { 194 | "id" : 23, 195 | "compiler" : "markdown", 196 | "input" : { 197 | "sessionId" : null, 198 | "code" : "\n### Step 2: Define Composite Features\n\n - \\\\(\\phi_{head} \\otimes \\phi_{child}\\\\), matrix \\\\(\\in \\Re^{n\\times n}\\\\) \n - \\\\(\\phi_{arc} \\otimes \\phi_{child}\\\\), matrix \\\\(\\in \\Re^{n\\times n}\\\\) \n - \\\\(\\phi_{head} \\otimes \\phi_{arc}\\\\), matrix \\\\(\\in \\Re^{n\\times n}\\\\) \n - \\\\(\\phi_{head} \\otimes \\phi_{child} \\otimes \\phi_{arc}\\\\), matrix \\\\(\\in \\Re^{n\\times n \\times n}\\\\) \n", 199 | "extraFields" : { 200 | "fragment" : "true" 201 | } 202 | } 203 | }, { 204 | "id" : 24, 205 | "compiler" : "section", 206 | "input" : { 207 | "sessionId" : null, 208 | "code" : "pstep2", 209 | "extraFields" : { } 210 | } 211 | }, { 212 | "id" : 25, 213 | "compiler" : "markdown", 214 | "input" : { 215 | "sessionId" : null, 216 | "code" : "### Step 3: Formulate Model Parameters Tensor\n\nA tensor \\\\(\\Re^{n \\times n \\times d}\\\\), describes the concatenation of all three feature vectors, so replace \\\\(\\Theta\\\\) with tensor \\\\(A\\\\):\n\n $$ S(\\mathbf{x},\\mathbf{y};\\mathbf{\\Theta}) = <\\phi_{head} \\otimes \\phi_{child} \\otimes \\phi_{arc},\\mathbf{\\Theta}> $$ \n\n Can be huge! A better option? Low rank approximation. Calculate A as: \n\n $$ \\mathbf{\\Theta} = \\mathbf{U} \\otimes \\mathbf{V} \\otimes \\mathbf{W} $$ \n\nwhere \\\\(U,V,\\\\) and \\\\(W\\\\) are dense low-dimensional representations \\\\(\\in \\Re^{n\\times r}\\\\) ", 217 | "extraFields" : { } 218 | } 219 | }, { 220 | "id" : 26, 221 | "compiler" : "section", 222 | "input" : { 223 | "sessionId" : null, 224 | "code" : "tobjectives1", 225 | "extraFields" : { } 226 | } 227 | }, { 228 | "id" : 27, 229 | "compiler" : "markdown", 230 | "input" : { 231 | "sessionId" : null, 232 | "code" : "### Learning\n\n Training Objective: \n\n $$ C \\sum_i \\eta_i + ||U||_F^2 + ||V||_F^2 + ||W||_F^2 + ||A||_F^2 $$ \n\nNon-convex optimization with regularization\n\nCan optimize with variant of Passive Aggressive (Crammer, 2006) \n", 233 | "extraFields" : { } 234 | } 235 | }, { 236 | "id" : 28, 237 | "compiler" : "section", 238 | "input" : { 239 | "sessionId" : null, 240 | "code" : "tobjectives2", 241 | "extraFields" : { } 242 | } 243 | }, { 244 | "id" : 29, 245 | "compiler" : "markdown", 246 | "input" : { 247 | "sessionId" : null, 248 | "code" : "### Learning\n\nOnline method tailored for tensors [Lei et al., 2014]\n\nIterate over data and for each instance, update unary feature weights \\\\(\\mathbf{\\theta}\\\\) and choose one of the feature tensors as follows (assuming \\\\(U\\\\) was chosen): \n\n - \\\\( \\theta^{(t + 1)} = \\theta^{(t)} + \\Delta \\theta \\\\) \n\n - \\\\( \\mathbf{U}^{(t+1)} = \\mathbf{U}^{(t)} + \\Delta \\mathbf{U} \\\\) \n\n With sub-problem (solvable with closed-form solution): \n\n $$ \\min_{\\Delta \\theta, \\Delta \\mathbf{U}} \\frac{1}{2} ||\\Delta \\mathbf{\\theta} ||_F^2 + \\frac{1}{2} ||\\Delta \\mathbf{U} ||_F^2 + C \\eta_i $$ ", 249 | "extraFields" : { } 250 | } 251 | }, { 252 | "id" : 30, 253 | "compiler" : "section", 254 | "input" : { 255 | "sessionId" : null, 256 | "code" : "parseresults", 257 | "extraFields" : { } 258 | } 259 | }, { 260 | "id" : 31, 261 | "compiler" : "markdown", 262 | "input" : { 263 | "sessionId" : null, 264 | "code" : "### Performance - Parsing\n\n\n\n- RBG + MF model trained with rank \\\\(r = 50\\\\) tensors\n\n- Results averaged over 14 languages (CoNLL data)", 265 | "extraFields" : { } 266 | } 267 | }, { 268 | "id" : 32, 269 | "compiler" : "section", 270 | "input" : { 271 | "sessionId" : null, 272 | "code" : "srlresults", 273 | "extraFields" : { } 274 | } 275 | }, { 276 | "id" : 33, 277 | "compiler" : "markdown", 278 | "input" : { 279 | "sessionId" : null, 280 | "code" : "### Performance - SRL\n\n\n\n - Baselines have many features and automatic feature selection\n\n - Outperforms previous best system across many languages", 281 | "extraFields" : { } 282 | } 283 | }, { 284 | "id" : 34, 285 | "compiler" : "section", 286 | "input" : { 287 | "sessionId" : null, 288 | "code" : "conclusion", 289 | "extraFields" : { } 290 | } 291 | }, { 292 | "id" : 35, 293 | "compiler" : "markdown", 294 | "input" : { 295 | "sessionId" : null, 296 | "code" : "### Conclusion \n\n* **Discriminative** models can be parameterized with matrices or tensors\n* **Low-rank** asumption enables **parameter sharing**\n * **Multi-task** learning: corresponds to label-embedding\n * **Vanilla matrix factorization** can be expressed as a \\\\(N\\times M\\\\)-dimensional **logistic regression with rank constraint**\n * **structured prediction** with low rank parameters can improve performance over heavily engineered state-of-the-art systems\n\n", 297 | "extraFields" : { } 298 | } 299 | } ], 300 | "config" : { } 301 | } 302 | -------------------------------------------------------------------------------- /src/main/moro/09_convex.json: -------------------------------------------------------------------------------- 1 | { 2 | "name" : "Convexification", 3 | "cells" : [ { 4 | "id" : 0, 5 | "compiler" : "section", 6 | "input" : { 7 | "sessionId" : null, 8 | "code" : "ConvexifyingMatrixFactorization", 9 | "extraFields" : { } 10 | } 11 | }, { 12 | "id" : 1, 13 | "compiler" : "markdown", 14 | "input" : { 15 | "sessionId" : null, 16 | "code" : "### Convexification\n\nMatrix \\\\( Y\\in\\Re^{n,d} \\\\). For any \\\\( K \\in \\mathbb{N} \\\\),\n\n(1) \\\\( \\min_{\\mathbf{U}\\in\\Re^{N\\times K},\\mathbf{V}\\in\\Re^{M\\times K}} \\|| \\mathbf{Y} - \\mathbf{U} \\mathbf{V}^T \\||_F \\\\)\n", 17 | "extraFields" : { } 18 | } 19 | }, { 20 | "id" : 2, 21 | "compiler" : "markdown", 22 | "input" : { 23 | "sessionId" : null, 24 | "code" : "Is equivalent to:\n\n(2) \\\\( \\min_{\\mathbf{X}\\in\\Re^{N\\times M},\\mathtt{rank}(\\mathbf{X})\\le K} \\|| \\mathbf{Y} - \\mathbf{X} \\||_F \\\\)\n", 25 | "extraFields" : { 26 | "fragment" : "true" 27 | } 28 | } 29 | }, { 30 | "id" : 3, 31 | "compiler" : "markdown", 32 | "input" : { 33 | "sessionId" : null, 34 | "code" : "Which is relaxed into:\n\n(3) \\\\( \\min_{\\mathbf{X}\\in\\Re^{N\\times M},\\||\\mathbf{X}||_*\\le K} \\|| \\mathbf{Y} - \\mathbf{X} \\||_F \\\\)\n", 35 | "extraFields" : { 36 | "fragment" : "true" 37 | } 38 | } 39 | }, { 40 | "id" : 4, 41 | "compiler" : "markdown", 42 | "input" : { 43 | "sessionId" : null, 44 | "code" : "(3) is convex, (2) is not", 45 | "extraFields" : { 46 | "fragment" : "true" 47 | } 48 | } 49 | }, { 50 | "id" : 5, 51 | "compiler" : "section", 52 | "input" : { 53 | "sessionId" : null, 54 | "code" : "Consequences", 55 | "extraFields" : { } 56 | } 57 | }, { 58 | "id" : 6, 59 | "compiler" : "markdown", 60 | "input" : { 61 | "sessionId" : null, 62 | "code" : "### What Do We Gain By Making the Problem Convex?\nWe have access to all the convex optimization tools!\n\n- Theoretical guarantees\n\n- More importantly, new algorithms\n\n\n", 63 | "extraFields" : { } 64 | } 65 | }, { 66 | "id" : 7, 67 | "compiler" : "section", 68 | "input" : { 69 | "sessionId" : null, 70 | "code" : "g", 71 | "extraFields" : { } 72 | } 73 | }, { 74 | "id" : 8, 75 | "compiler" : "markdown", 76 | "input" : { 77 | "sessionId" : null, 78 | "code" : "### Theory\n\n- Convergence to the global optimum, no need for smart initialization\n- Speed of convergences\n- Polynomial time guarantees for a fixed accuracy \n", 79 | "extraFields" : { } 80 | } 81 | }, { 82 | "id" : 9, 83 | "compiler" : "section", 84 | "input" : { 85 | "sessionId" : null, 86 | "code" : "newalgos", 87 | "extraFields" : { } 88 | } 89 | }, { 90 | "id" : 10, 91 | "compiler" : "markdown", 92 | "input" : { 93 | "sessionId" : null, 94 | "code" : "### New Algorithms\n\n- Proximal methods (ISTA and FISTA)\n", 95 | "extraFields" : { } 96 | } 97 | }, { 98 | "id" : 11, 99 | "compiler" : "markdown", 100 | "input" : { 101 | "sessionId" : null, 102 | "code" : "- Frank-Wolfe (Conjugate Gradient) algorithms\n", 103 | "extraFields" : { } 104 | } 105 | }, { 106 | "id" : 12, 107 | "compiler" : "markdown", 108 | "input" : { 109 | "sessionId" : null, 110 | "code" : "- Augmented Lagrangian approaches (ADMM, splitting methods)\n", 111 | "extraFields" : { } 112 | } 113 | }, { 114 | "id" : 13, 115 | "compiler" : "markdown", 116 | "input" : { 117 | "sessionId" : null, 118 | "code" : "- Stochastic variants (e.g. SAG)", 119 | "extraFields" : { } 120 | } 121 | }, { 122 | "id" : 14, 123 | "compiler" : "section", 124 | "input" : { 125 | "sessionId" : null, 126 | "code" : "CombiningRegularization", 127 | "extraFields" : { } 128 | } 129 | }, { 130 | "id" : 15, 131 | "compiler" : "markdown", 132 | "input" : { 133 | "sessionId" : null, 134 | "code" : "### Combining Regularizations\n\nConvex penalties can be added to get better models\n\n- Sparse plus low-rank\n\n \\\\( \\min_{\\mathbf{S},\\mathbf{L}} \\ell(\\mathbf{S}+\\mathbf{L};\\mathbf{Y}) + \\lambda||\\mathbf{S}||_1 + \\mu||\\mathbf{L}||_* \\\\)\n \n \n Sum of trace norms\n\n \\\\( \\min_{\\mathbf{L}_1,\\mathbf{L}_2} \\ell(\\mathbf{X};\\mathbf{Y}) + \\lambda_1||\\mathrm{blk}_1(\\mathbf{X})||_* + \\lambda_2||\\mathrm{blk}_2(\\mathbf{X})||_* \n\\\\)\n\ne.g.: Convex Cannonical Correlation Analysis\n\nVery popular in image processing ==> should also be useful in NLP!\n\n\n", 135 | "extraFields" : { } 136 | } 137 | }, { 138 | "id" : 16, 139 | "compiler" : "section", 140 | "input" : { 141 | "sessionId" : null, 142 | "code" : "Section", 143 | "extraFields" : { } 144 | } 145 | }, { 146 | "id" : 17, 147 | "compiler" : "markdown", 148 | "input" : { 149 | "sessionId" : null, 150 | "code" : "### Some Pointers to Convex Factorization\n\n* **2001**: Fazel, Hindi & Boyd. \"A rank minimization heuristic with application to minimum order system approximation.\n* **2009**: Candès & Recht. \"Exact matrix completion via convex optimization.\".\n* **2009**: Wright, Ganesh, Rao, Peng & Ma. \"Robust principal component analysis\".\n* **2009**: Hsu, Kakade and Zhang. A Spectral Algorithm for Learning Hidden Markov Models\n* **2011**: Tamioka & Suzu. Statistical performance of convex tensor decomposition.\n* **2013**: Bouchard, Guo & Yin. Convex Collective Matrix Factorization.\n* **2014**: Bailly, Carreras & Quattoni: Unsupervised Spectral Learning of Finite-state Transducers\n", 151 | "extraFields" : { } 152 | } 153 | }, { 154 | "id" : 18, 155 | "compiler" : "section", 156 | "input" : { 157 | "sessionId" : null, 158 | "code" : "Spectral", 159 | "extraFields" : { } 160 | } 161 | }, { 162 | "id" : 19, 163 | "compiler" : "markdown", 164 | "input" : { 165 | "sessionId" : null, 166 | "code" : "### Application: Spectral Learning in NLP\n\nA promising application of convex factorization: **polynomial-time** learning of \n\n* HMMs\n* WFSAs\n* Grammars\n* Even NMF!\n\n*Idea*: factorization of redundant moment matrices. \n\n", 167 | "extraFields" : { } 168 | } 169 | }, { 170 | "id" : 20, 171 | "compiler" : "section", 172 | "input" : { 173 | "sessionId" : null, 174 | "code" : "spec", 175 | "extraFields" : { } 176 | } 177 | }, { 178 | "id" : 21, 179 | "compiler" : "markdown", 180 | "input" : { 181 | "sessionId" : null, 182 | "code" : "### Example: Empirical Hankel Matrix of a String \n\nMatrix of counts of all possible prefixes and suffixes \n\n", 183 | "extraFields" : { } 184 | } 185 | }, { 186 | "id" : 22, 187 | "compiler" : "section", 188 | "input" : { 189 | "sessionId" : null, 190 | "code" : "conclusion", 191 | "extraFields" : { } 192 | } 193 | }, { 194 | "id" : 23, 195 | "compiler" : "markdown", 196 | "input" : { 197 | "sessionId" : null, 198 | "code" : "### Summary of Convex Factorization\n\n* **Trace norm** is great\n * from intractable to tractable problems\n* **Spectral learning** combines well with trace norm\n * Learning latent variable with computational guarantees\n \n", 199 | "extraFields" : { } 200 | } 201 | } ], 202 | "config" : { } 203 | } 204 | -------------------------------------------------------------------------------- /src/main/moro/10_summary.json: -------------------------------------------------------------------------------- 1 | { 2 | "name" : "Summary", 3 | "cells" : [ { 4 | "id" : 0, 5 | "compiler" : "section", 6 | "input" : { 7 | "sessionId" : null, 8 | "code" : "bef", 9 | "extraFields" : { } 10 | } 11 | }, { 12 | "id" : 1, 13 | "compiler" : "markdown", 14 | "input" : { 15 | "sessionId" : null, 16 | "code" : "### Before the break\n\n1. Matrices/Tensor = natural concepts for relations\n2. Low-Rank = natural regularization\n3. Non-negativity => Clustering\n4. Binary loss: much better than squared loss\n ", 17 | "extraFields" : { } 18 | } 19 | }, { 20 | "id" : 2, 21 | "compiler" : "section", 22 | "input" : { 23 | "sessionId" : null, 24 | "code" : "aft", 25 | "extraFields" : { } 26 | } 27 | }, { 28 | "id" : 3, 29 | "compiler" : "markdown", 30 | "input" : { 31 | "sessionId" : null, 32 | "code" : "### After the break\n\n5. Prior knowledge included using *logic*-based loss models\n6. Multi-relational learning\n - Tensors: *many* different possible factorizations\n - Collective Matrix Factorization for *typed* data\n8. Discriminative factoriation\n - Reduced rank regression/Multi-task learning\n - Factorization machines\n - Structured prediction\n9. Convexification\n - The *trace norm* is a real breakthrough\n - Theoretical guarantees, new algorithms, structured regularization", 33 | "extraFields" : { } 34 | } 35 | }, { 36 | "id" : 4, 37 | "compiler" : "section", 38 | "input" : { 39 | "sessionId" : null, 40 | "code" : "takehome", 41 | "extraFields" : { } 42 | } 43 | }, { 44 | "id" : 5, 45 | "compiler" : "markdown", 46 | "input" : { 47 | "sessionId" : null, 48 | "code" : "### Take-home messages\n\nNLP is about learning relations. Low-rank factorization simply *works*\n\n- in *theory*: well understood model with nearly **linear-time** complexity\n- in *practice*: many **large scale** examples\n\nThe real reason why it works: \n\nReplaces **combinatorics** by **linear algebra**\n\n\n", 49 | "extraFields" : { } 50 | } 51 | }, { 52 | "id" : 6, 53 | "compiler" : "section", 54 | "input" : { 55 | "sessionId" : null, 56 | "code" : "toolkits", 57 | "extraFields" : { } 58 | } 59 | }, { 60 | "id" : 7, 61 | "compiler" : "markdown", 62 | "input" : { 63 | "sessionId" : null, 64 | "code" : "### Toolkits\n\n- R Package for Collective Matrix Factorization (Klami)\n[https://cran.r-project.org/web/packages/CMF]()\n\n- MyMediaLite (Ganter & Rendle): [http://mymedialite.net/news/index.html]()\n\n- scikit-tensor (Nickel): [http://github.com/mnick/scikit-tensor]()\n\n- NMF-MATLAB (Yi & Ngom): [https://sites.google.com/site/nmftool/]()\n\n- Theano (Bengio et al.): [http://deeplearning.net/software/theano/]()\n\n- Wolfe (Riedel et al.): [http://www.wolfe.ml]()\n - used in this presentation via Moro by Sameer Singh\n", 65 | "extraFields" : { } 66 | } 67 | }, { 68 | "id" : 8, 69 | "compiler" : "section", 70 | "input" : { 71 | "sessionId" : null, 72 | "code" : "end", 73 | "extraFields" : { } 74 | } 75 | }, { 76 | "id" : 9, 77 | "compiler" : "markdown", 78 | "input" : { 79 | "sessionId" : null, 80 | "code" : "\n\n", 81 | "extraFields" : { } 82 | } 83 | } ], 84 | "config" : { } 85 | } 86 | -------------------------------------------------------------------------------- /src/main/moro/SGD_converges_to_SVD.json: -------------------------------------------------------------------------------- 1 | { 2 | "name" : "SGD converges to SVD", 3 | "cells" : [ { 4 | "id" : 0, 5 | "compiler" : "section", 6 | "input" : { 7 | "sessionId" : null, 8 | "code" : "Interactive", 9 | "extraFields" : { } 10 | } 11 | }, { 12 | "id" : 1, 13 | "compiler" : "scala", 14 | "input" : { 15 | "sessionId" : null, 16 | "code" : "import uk.ac.ucl.cs.mr.acltutorial.ManualMF._\nimport uk.ac.ucl.cs.mr.acltutorial.MatrixRenderer._\nimport uk.ac.ucl.cs.mr.acltutorial.Renderer._\nimport cc.factorie.la.{DenseTensor2, DenseTensor1}\nimport ml.wolfe.{Mat, Vect}\nimport org.sameersingh.scalaplot._\n\nval layout = Layout(cw = 80, ch = 50, colHeaderSize = 150)\n\ndef plot(x:Seq[Double],y:Seq[Double]):XYChart = {\n xyChart(new XYData(new MemXYSeries(x,y)))\n}\ndef plot(x1:Seq[Double],y1:Seq[Double],s1:String,x2:Seq[Double],y2:Seq[Double],s2:String):XYChart = {\n var c = xyChart(new XYData(new MemXYSeries(x1,y1,s1),new MemXYSeries(x2,y2,s2)))\n c.showLegend = true\n c\n}\n\nplot(Seq(1.0,2.0,2.5),Seq(2.0,1.0,2.1),\"a\",Seq(1.0,2.0,2.5),Seq(2.2,1.1,2.0),\"b\")\n\n", 17 | "extraFields" : { 18 | "aggregatedCells" : "[]" 19 | } 20 | } 21 | }, { 22 | "id" : 2, 23 | "compiler" : "scala", 24 | "input" : { 25 | "sessionId" : null, 26 | "code" : "val n = 5\nval m = 5 \nval M2 = new DenseTensor2(n, m)\nval rand = new scala.util.Random(0)\nval rowNames = Seq(\"D1\",\"D2\",\"D3\",\"D4\",\"D5\")\nval colNames = Seq(\"Greece\",\"Tsipras\",\"Germany\",\"crisis\",\"economy\")\nval names = header(rowNames,colNames)\nval M = parseMatrix(\n \"\"\"1 2 0 0 0\n 0 0 1 0 0\n 0 0 0 1 1 \n 0 0 1 1 1\n 1 2 1 1 0\"\"\")\nfor (i <- 0 until m; j <- 0 until m) {\n M2(i, j) = rand.nextGaussian()\n}", 27 | "extraFields" : { 28 | "hide_output" : "true", 29 | "aggregatedCells" : "[\"import uk.ac.ucl.cs.mr.acltutorial.ManualMF._\\nimport uk.ac.ucl.cs.mr.acltutorial.MatrixRenderer._\\nimport uk.ac.ucl.cs.mr.acltutorial.Renderer._\\nimport cc.factorie.la.{DenseTensor2, DenseTensor1}\\nimport ml.wolfe.{Mat, Vect}\\nimport org.sameersingh.scalaplot._\\n\\nval layout = Layout(cw = 80, ch = 50, colHeaderSize = 150)\\n\\ndef plot(x:Seq[Double],y:Seq[Double]):XYChart = {\\n xyChart(new XYData(new MemXYSeries(x,y)))\\n}\\ndef plot(x1:Seq[Double],y1:Seq[Double],s1:String,x2:Seq[Double],y2:Seq[Double],s2:String):XYChart = {\\n var c = xyChart(new XYData(new MemXYSeries(x1,y1,s1),new MemXYSeries(x2,y2,s2)))\\n c.showLegend = true\\n c\\n}\\n\\nplot(Seq(1.0,2.0,2.5),Seq(2.0,1.0,2.1),\\\"a\\\",Seq(1.0,2.0,2.5),Seq(2.2,1.1,2.0),\\\"b\\\")\\n\\n\"]" 30 | } 31 | } 32 | }, { 33 | "id" : 3, 34 | "compiler" : "section", 35 | "input" : { 36 | "sessionId" : null, 37 | "code" : "SGD", 38 | "extraFields" : { } 39 | } 40 | }, { 41 | "id" : 4, 42 | "compiler" : "scala", 43 | "input" : { 44 | "sessionId" : null, 45 | "code" : "def optimizeL2(M: Mat, K: Int, iters: Int, alpha:Double = 0.1, initScale:Double = 1.0): (Seq[Vect], Seq[Vect]) = {\n val rand = new scala.util.Random(0)\n val AV = initialAV(K, M.dim1, M.dim2, initScale)\n val A = AV._1; val V = AV._2\n def update(i: Int, j: Int) = {\n val a = A(i).copy\n val v = V(j).copy\n val y = a dot v\n A(i) += v * alpha * (M(i, j) - y)\n V(j) += a * alpha * (M(i, j) - y)\n }\n for (i <- Range(0,iters).toList) {\n update(rand.nextInt(M.dim1), \n rand.nextInt(M.dim2))\n }\n (A, V)\n}", 46 | "extraFields" : { 47 | "hide_output" : "true", 48 | "aggregatedCells" : "[\"import uk.ac.ucl.cs.mr.acltutorial.ManualMF._\\nimport uk.ac.ucl.cs.mr.acltutorial.MatrixRenderer._\\nimport uk.ac.ucl.cs.mr.acltutorial.Renderer._\\nimport cc.factorie.la.{DenseTensor2, DenseTensor1}\\nimport ml.wolfe.{Mat, Vect}\\nimport org.sameersingh.scalaplot._\\n\\nval layout = Layout(cw = 80, ch = 50, colHeaderSize = 150)\\n\\ndef plot(x:Seq[Double],y:Seq[Double]):XYChart = {\\n xyChart(new XYData(new MemXYSeries(x,y)))\\n}\\ndef plot(x1:Seq[Double],y1:Seq[Double],s1:String,x2:Seq[Double],y2:Seq[Double],s2:String):XYChart = {\\n var c = xyChart(new XYData(new MemXYSeries(x1,y1,s1),new MemXYSeries(x2,y2,s2)))\\n c.showLegend = true\\n c\\n}\\n\\nplot(Seq(1.0,2.0,2.5),Seq(2.0,1.0,2.1),\\\"a\\\",Seq(1.0,2.0,2.5),Seq(2.2,1.1,2.0),\\\"b\\\")\\n\\n\",\"val n = 5\\nval m = 5 \\nval M2 = new DenseTensor2(n, m)\\nval rand = new scala.util.Random(0)\\nval rowNames = Seq(\\\"D1\\\",\\\"D2\\\",\\\"D3\\\",\\\"D4\\\",\\\"D5\\\")\\nval colNames = Seq(\\\"Greece\\\",\\\"Tsipras\\\",\\\"Germany\\\",\\\"crisis\\\",\\\"economy\\\")\\nval names = header(rowNames,colNames)\\nval M = parseMatrix(\\n \\\"\\\"\\\"1 2 0 0 0\\n 0 0 1 0 0\\n 0 0 0 1 1 \\n 0 0 1 1 1\\n 1 2 1 1 0\\\"\\\"\\\")\\nfor (i <- 0 until m; j <- 0 until m) {\\n M2(i, j) = rand.nextGaussian()\\n}\"]" 49 | } 50 | } 51 | }, { 52 | "id" : 5, 53 | "compiler" : "section", 54 | "input" : { 55 | "sessionId" : null, 56 | "code" : "aaa", 57 | "extraFields" : { } 58 | } 59 | }, { 60 | "id" : 6, 61 | "compiler" : "scala", 62 | "input" : { 63 | "sessionId" : null, 64 | "code" : "val K = 2 //rank \nval x = Range(0,10).map(_.toDouble)\nval models = for (i <- x.map(_.toInt)) yield optimizeL2(M, K, i * 100, 0.1)\nval ySGD = models.map(m => l2Loss(M,dots(m._1,m._2)))\nval (u,s,v) = breezeSVD(M)\nval (ea,ev) = toEmbeddings(u,s,v,K)\nval ySVD = l2Loss(M,dots(ea,ev))\nval c = plot(x,ySGD,\"L2-loss SGD\",Seq(0.0,10.0),Seq(ySVD,ySVD),\"SVD\")\nc.size = (500.0 -> 200.0)\nc//ml.wolfe.ui.D3Plotter.lineplot(c)", 65 | "extraFields" : { 66 | "aggregatedCells" : "[\"import uk.ac.ucl.cs.mr.acltutorial.ManualMF._\\nimport uk.ac.ucl.cs.mr.acltutorial.MatrixRenderer._\\nimport uk.ac.ucl.cs.mr.acltutorial.Renderer._\\nimport cc.factorie.la.{DenseTensor2, DenseTensor1}\\nimport ml.wolfe.{Mat, Vect}\\nimport org.sameersingh.scalaplot._\\n\\nval layout = Layout(cw = 80, ch = 50, colHeaderSize = 150)\\n\\ndef plot(x:Seq[Double],y:Seq[Double]):XYChart = {\\n xyChart(new XYData(new MemXYSeries(x,y)))\\n}\\ndef plot(x1:Seq[Double],y1:Seq[Double],s1:String,x2:Seq[Double],y2:Seq[Double],s2:String):XYChart = {\\n var c = xyChart(new XYData(new MemXYSeries(x1,y1,s1),new MemXYSeries(x2,y2,s2)))\\n c.showLegend = true\\n c\\n}\\n\\nplot(Seq(1.0,2.0,2.5),Seq(2.0,1.0,2.1),\\\"a\\\",Seq(1.0,2.0,2.5),Seq(2.2,1.1,2.0),\\\"b\\\")\\n\\n\",\"val n = 5\\nval m = 5 \\nval M2 = new DenseTensor2(n, m)\\nval rand = new scala.util.Random(0)\\nval rowNames = Seq(\\\"D1\\\",\\\"D2\\\",\\\"D3\\\",\\\"D4\\\",\\\"D5\\\")\\nval colNames = Seq(\\\"Greece\\\",\\\"Tsipras\\\",\\\"Germany\\\",\\\"crisis\\\",\\\"economy\\\")\\nval names = header(rowNames,colNames)\\nval M = parseMatrix(\\n \\\"\\\"\\\"1 2 0 0 0\\n 0 0 1 0 0\\n 0 0 0 1 1 \\n 0 0 1 1 1\\n 1 2 1 1 0\\\"\\\"\\\")\\nfor (i <- 0 until m; j <- 0 until m) {\\n M2(i, j) = rand.nextGaussian()\\n}\",\"def optimizeL2(M: Mat, K: Int, iters: Int, alpha:Double = 0.1, initScale:Double = 1.0): (Seq[Vect], Seq[Vect]) = {\\n val rand = new scala.util.Random(0)\\n val AV = initialAV(K, M.dim1, M.dim2, initScale)\\n val A = AV._1; val V = AV._2\\n def update(i: Int, j: Int) = {\\n val a = A(i).copy\\n val v = V(j).copy\\n val y = a dot v\\n A(i) += v * alpha * (M(i, j) - y)\\n V(j) += a * alpha * (M(i, j) - y)\\n }\\n for (i <- Range(0,iters).toList) {\\n update(rand.nextInt(M.dim1), \\n rand.nextInt(M.dim2))\\n }\\n (A, V)\\n}\"]" 67 | } 68 | } 69 | } ], 70 | "config" : { } 71 | } 72 | -------------------------------------------------------------------------------- /src/main/moro/biblio.json: -------------------------------------------------------------------------------- 1 | { 2 | "name" : "Annotated Bibliography", 3 | "cells" : [ { 4 | "id" : 0, 5 | "compiler" : "section", 6 | "input" : { 7 | "sessionId" : null, 8 | "code" : "blah", 9 | "extraFields" : { 10 | "aggregatedCells" : "[]" 11 | } 12 | } 13 | }, { 14 | "id" : 1, 15 | "compiler" : "html", 16 | "input" : { 17 | "sessionId" : null, 18 | "code" : "
\nKolda, Tamara G., and Brett W. Bader. \"Tensor decompositions and applications.\" SIAM review 51.3 (2009): 455-500. \n
\nExtensive overview of the topic, we adopted their notation in the tutorial\n
\n
\nGoldberg, Andrew B., Zhu, Xiaojin, Recht, Benjamin, Xu, Jun-Ming, Nowak, Robert. \"Transduction with Matrix Completion: Three Birds with One Stone.\" In Advances in Neural Information Processing Systems (NIPS) 24. 2010.\n
\nFirst work to formulate semi-supervised multi-task learning with missing data explicitly as matrix completion\n

\nKoren, Yehuda, Robert Bell, and Chris Volinsky. \"Matrix factorization techniques for recommender systems.\" Computer 8 (2009): 30-37.\n
\nDescription of SGD and ALS algoirthms for matrix factorization\n
", 19 | "extraFields" : { } 20 | } 21 | }, { 22 | "id" : 2, 23 | "compiler" : "section", 24 | "input" : { 25 | "sessionId" : null, 26 | "code" : "bla", 27 | "extraFields" : { } 28 | } 29 | }, { 30 | "id" : 3, 31 | "compiler" : "html", 32 | "input" : { 33 | "sessionId" : null, 34 | "code" : "
\nWang, Quan, et al. \"Regularized latent semantic indexing.\" Proceedings of the 34th international ACM SIGIR conference on Research and development in Information Retrieval. ACM, 2011.\n
\nIntroduces regularized latent semantic indexing\n

\nLee, Daniel D., and H. Sebastian Seung. \"Algorithms for non-negative matrix factorization.\" Advances in Neural Information Processing Systems (NIPS) 15. 2001.\n
\nMultiplicative updates algorithm for NMF\n

\nKim, Hyunsoo, and Haesun Park. \"Nonnegative matrix factorization based on alternating nonnegativity constrained least squares and active set method.\" SIAM Journal on Matrix Analysis and Applications 30.2 (2008): 713-730.\n
\n Alternating least squares for NMF\n
", 35 | "extraFields" : { } 36 | } 37 | }, { 38 | "id" : 4, 39 | "compiler" : "section", 40 | "input" : { 41 | "sessionId" : null, 42 | "code" : "bl", 43 | "extraFields" : { } 44 | } 45 | }, { 46 | "id" : 5, 47 | "compiler" : "html", 48 | "input" : { 49 | "sessionId" : null, 50 | "code" : "
\nGaussier, Eric, and Cyril Goutte. \"Relation between PLSA and NMF and implications.\" Proceedings of the 28th annual international ACM SIGIR conference on Research and development in information retrieval. ACM, 2005.\n
\nFirst paper to point out the connection between PLSA and NMF\n

\nArora, Sanjeev, Rong Ge, and Ankur Moitra. \"Learning topic models--going beyond SVD.\" Foundations of Computer Science (FOCS), 2012 IEEE 53rd Annual Symposium on. IEEE, 2012.\n
\nTheoretical justification of topic modeling as NMF\n
", 51 | "extraFields" : { } 52 | } 53 | }, { 54 | "id" : 6, 55 | "compiler" : "section", 56 | "input" : { 57 | "sessionId" : null, 58 | "code" : "b", 59 | "extraFields" : { } 60 | } 61 | }, { 62 | "id" : 7, 63 | "compiler" : "markdown", 64 | "input" : { 65 | "sessionId" : null, 66 | "code" : "
\nTucker, Ledyard R. \"Some mathematical notes on three-mode factor analysis.\" Psychometrika 31.3 (1966): 279-311.\n
\n
\nCarroll, J. Douglas, and Jih-Jie Chang. \"Analysis of individual differences in multidimensional scaling via an N-way generalization of “Eckart-Young” decomposition.\" Psychometrika 35.3 (1970): 283-319.\n

\nHarshman, Richard A. \"Foundations of the PARAFAC procedure: Models and conditions for an\" explanatory\" multi-modal factor analysis.\" (1970): 1-84.\nAPA\n
", 67 | "extraFields" : { } 68 | } 69 | }, { 70 | "id" : 8, 71 | "compiler" : "section", 72 | "input" : { 73 | "sessionId" : null, 74 | "code" : "moreb", 75 | "extraFields" : { } 76 | } 77 | }, { 78 | "id" : 9, 79 | "compiler" : "html", 80 | "input" : { 81 | "sessionId" : null, 82 | "code" : "
\nNickel, Maximilian, Volker Tresp, and Hans-Peter Kriegel. \"A three-way model for collective learning on multi-relational data.\" Proceedings of the 28th international conference on machine learning (ICML-11). 2011.\n

\nNickel, Maximilian, Volker Tresp, and Hans-Peter Kriegel. \"Factorizing YAGO: scalable machine learning for linked data.\" Proceedings of the 21st international conference on World Wide Web. ACM, 2012.\nAPA\n

\nGoller, Christoph, and Andreas Kuchler. \"Learning task-dependent distributed representations by backpropagation through structure.\" Neural Networks, 1996., IEEE International Conference on. Vol. 1. IEEE, 1996.\n
", 83 | "extraFields" : { } 84 | } 85 | }, { 86 | "id" : 10, 87 | "compiler" : "section", 88 | "input" : { 89 | "sessionId" : null, 90 | "code" : "j", 91 | "extraFields" : { } 92 | } 93 | }, { 94 | "id" : 11, 95 | "compiler" : "html", 96 | "input" : { 97 | "sessionId" : null, 98 | "code" : "
\nKoby Crammer, Ofer Dekel, Joseph Keshet, Shia Shalev-Shwartz, and Yoram Singer. \"Online Passive-Aggressive Algorithms\".JMLR. 2006. \n

\n Tao Lei, Yu Xin, Yuan Zhang, Regina Barzilay and Tommi Jaakkola. \" Low-Rank Tensors for Scoring Dependency Structures.\"In Proceedings of the 52nd Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pp 1381--1391, Baltimore, Maryland, June. \n

\n Hai Zhao, Wenliang Chen, Chunyu Kit, Guodong Zhou. \"Multilingual Dependency Learning: A Huge Feature Engineering Method to Semantic Dependency Parsing\", CoNLL, 2009.\n
", 99 | "extraFields" : { } 100 | } 101 | }, { 102 | "id" : 12, 103 | "compiler" : "section", 104 | "input" : { 105 | "sessionId" : null, 106 | "code" : "k", 107 | "extraFields" : { } 108 | } 109 | }, { 110 | "id" : 13, 111 | "compiler" : "html", 112 | "input" : { 113 | "sessionId" : null, 114 | "code" : "
\nRendle, Steffen. \"Factorization machines.\" Data Mining (ICDM), 2010 IEEE 10th International Conference on. IEEE, 2010.\n

\nCohen, S. B., Stratos, K., Collins, M., Foster, D. P., and Ungar, L. 2014. Spectral learning of latent-variable PCFGs: Algorithms and sample complexity. Journal of Machine Learning Research.\n

\nBailly, R., Carreras, X., Luque, F., and Quattoni, A. 2013.\nUnsupervised spectral learning of WCFG as low-rank matrix\ncompletion.\n

\nKlami, Arto, Guillaume Bouchard, and Abhishek Tripathi. \"Group-sparse Embeddings in Collective Matrix Factorization.\" Proceedings of International Conference on Learning Representations (ICLR) 2014.\n

\n
", 115 | "extraFields" : { } 116 | } 117 | }, { 118 | "id" : 14, 119 | "compiler" : "section", 120 | "input" : { 121 | "sessionId" : null, 122 | "code" : "l", 123 | "extraFields" : { } 124 | } 125 | }, { 126 | "id" : 15, 127 | "compiler" : "html", 128 | "input" : { 129 | "sessionId" : null, 130 | "code" : "
\nSalakhutdinov, Ruslan, and Andriy Mnih. \"Bayesian probabilistic matrix factorization using Markov chain Monte Carlo.\" Proceedings of the 25th international conference on Machine learning. ACM, 2008.\n

\nMohamed, Shakir, Zoubin Ghahramani, and Katherine A. Heller. \"Bayesian exponential family PCA.\" Advances in Neural Information Processing Systems. 2009.\n

\nStern, David H., Ralf Herbrich, and Thore Graepel. \"Matchbox: large scale online bayesian recommendations.\" Proceedings of the 18th international conference on World wide web. ACM, 2009.\n

\nRaiko, Tapani, Alexander Ilin, and Juha Karhunen. \"Principal component analysis for sparse high-dimensional data.\" Neural Information Processing. Springer Berlin Heidelberg, 2008.\n
", 131 | "extraFields" : { } 132 | } 133 | } ], 134 | "config" : { } 135 | } 136 | -------------------------------------------------------------------------------- /src/main/moro/figures/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/.DS_Store -------------------------------------------------------------------------------- /src/main/moro/figures/00/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/00/.DS_Store -------------------------------------------------------------------------------- /src/main/moro/figures/00/mf_intro.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/00/mf_intro.png -------------------------------------------------------------------------------- /src/main/moro/figures/00/mfw1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/00/mfw1.png -------------------------------------------------------------------------------- /src/main/moro/figures/00/mfw2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/00/mfw2.png -------------------------------------------------------------------------------- /src/main/moro/figures/00/mfw3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/00/mfw3.png -------------------------------------------------------------------------------- /src/main/moro/figures/00/s1f1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/00/s1f1.png -------------------------------------------------------------------------------- /src/main/moro/figures/00/s1f2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/00/s1f2.png -------------------------------------------------------------------------------- /src/main/moro/figures/04/i20.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/04/i20.png -------------------------------------------------------------------------------- /src/main/moro/figures/04/i200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/04/i200.png -------------------------------------------------------------------------------- /src/main/moro/figures/04/identity-geom.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/04/identity-geom.png -------------------------------------------------------------------------------- /src/main/moro/figures/04/identity-geom.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/04/identity-geom.pptx -------------------------------------------------------------------------------- /src/main/moro/figures/04/identity200x200.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/04/identity200x200.pdf -------------------------------------------------------------------------------- /src/main/moro/figures/04/identity20x20.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/04/identity20x20.pdf -------------------------------------------------------------------------------- /src/main/moro/figures/04/identity60x60.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/04/identity60x60.pdf -------------------------------------------------------------------------------- /src/main/moro/figures/04/sequence-pred-logit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/04/sequence-pred-logit.png -------------------------------------------------------------------------------- /src/main/moro/figures/04/sequence-pred-squared.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/04/sequence-pred-squared.png -------------------------------------------------------------------------------- /src/main/moro/figures/04/sequence-train.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/04/sequence-train.png -------------------------------------------------------------------------------- /src/main/moro/figures/04/transitivityGroup10pct-logistic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/04/transitivityGroup10pct-logistic.png -------------------------------------------------------------------------------- /src/main/moro/figures/04/transitivityGroup10pct-squared.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/04/transitivityGroup10pct-squared.png -------------------------------------------------------------------------------- /src/main/moro/figures/04/transitivityGroup10pct-training.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/04/transitivityGroup10pct-training.png -------------------------------------------------------------------------------- /src/main/moro/figures/06/cmf_databases.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/06/cmf_databases.png -------------------------------------------------------------------------------- /src/main/moro/figures/06/faces.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/06/faces.png -------------------------------------------------------------------------------- /src/main/moro/figures/06/faces_expt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/06/faces_expt.png -------------------------------------------------------------------------------- /src/main/moro/figures/06/gene_expression.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/06/gene_expression.png -------------------------------------------------------------------------------- /src/main/moro/figures/06/relational_database_health.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/06/relational_database_health.png -------------------------------------------------------------------------------- /src/main/moro/figures/07/Backprop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/07/Backprop.png -------------------------------------------------------------------------------- /src/main/moro/figures/07/Baselines-0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/07/Baselines-0.png -------------------------------------------------------------------------------- /src/main/moro/figures/07/Baselines-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/07/Baselines-1.png -------------------------------------------------------------------------------- /src/main/moro/figures/07/Baselines-10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/07/Baselines-10.png -------------------------------------------------------------------------------- /src/main/moro/figures/07/Baselines-11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/07/Baselines-11.png -------------------------------------------------------------------------------- /src/main/moro/figures/07/Baselines-12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/07/Baselines-12.png -------------------------------------------------------------------------------- /src/main/moro/figures/07/Baselines-13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/07/Baselines-13.png -------------------------------------------------------------------------------- /src/main/moro/figures/07/Baselines-14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/07/Baselines-14.png -------------------------------------------------------------------------------- /src/main/moro/figures/07/Baselines-15.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/07/Baselines-15.png -------------------------------------------------------------------------------- /src/main/moro/figures/07/Baselines-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/07/Baselines-2.png -------------------------------------------------------------------------------- /src/main/moro/figures/07/Baselines-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/07/Baselines-3.png -------------------------------------------------------------------------------- /src/main/moro/figures/07/Baselines-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/07/Baselines-4.png -------------------------------------------------------------------------------- /src/main/moro/figures/07/Baselines-5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/07/Baselines-5.png -------------------------------------------------------------------------------- /src/main/moro/figures/07/Baselines-6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/07/Baselines-6.png -------------------------------------------------------------------------------- /src/main/moro/figures/07/Baselines-7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/07/Baselines-7.png -------------------------------------------------------------------------------- /src/main/moro/figures/07/Baselines-8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/07/Baselines-8.png -------------------------------------------------------------------------------- /src/main/moro/figures/07/Baselines-9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/07/Baselines-9.png -------------------------------------------------------------------------------- /src/main/moro/figures/07/MF-0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/07/MF-0.png -------------------------------------------------------------------------------- /src/main/moro/figures/07/MF-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/07/MF-1.png -------------------------------------------------------------------------------- /src/main/moro/figures/07/MF-10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/07/MF-10.png -------------------------------------------------------------------------------- /src/main/moro/figures/07/MF-11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/07/MF-11.png -------------------------------------------------------------------------------- /src/main/moro/figures/07/MF-12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/07/MF-12.png -------------------------------------------------------------------------------- /src/main/moro/figures/07/MF-13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/07/MF-13.png -------------------------------------------------------------------------------- /src/main/moro/figures/07/MF-14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/07/MF-14.png -------------------------------------------------------------------------------- /src/main/moro/figures/07/MF-15.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/07/MF-15.png -------------------------------------------------------------------------------- /src/main/moro/figures/07/MF-16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/07/MF-16.png -------------------------------------------------------------------------------- /src/main/moro/figures/07/MF-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/07/MF-2.png -------------------------------------------------------------------------------- /src/main/moro/figures/07/MF-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/07/MF-3.png -------------------------------------------------------------------------------- /src/main/moro/figures/07/MF-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/07/MF-4.png -------------------------------------------------------------------------------- /src/main/moro/figures/07/MF-5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/07/MF-5.png -------------------------------------------------------------------------------- /src/main/moro/figures/07/MF-6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/07/MF-6.png -------------------------------------------------------------------------------- /src/main/moro/figures/07/MF-7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/07/MF-7.png -------------------------------------------------------------------------------- /src/main/moro/figures/07/MF-8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/07/MF-8.png -------------------------------------------------------------------------------- /src/main/moro/figures/07/MF-9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/07/MF-9.png -------------------------------------------------------------------------------- /src/main/moro/figures/07/Overview-0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/07/Overview-0.png -------------------------------------------------------------------------------- /src/main/moro/figures/07/Overview-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/07/Overview-1.png -------------------------------------------------------------------------------- /src/main/moro/figures/07/Overview-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/07/Overview-2.png -------------------------------------------------------------------------------- /src/main/moro/figures/07/Overview-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/07/Overview-3.png -------------------------------------------------------------------------------- /src/main/moro/figures/07/Overview-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/07/Overview-4.png -------------------------------------------------------------------------------- /src/main/moro/figures/07/Overview-5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/07/Overview-5.png -------------------------------------------------------------------------------- /src/main/moro/figures/07/Overview-6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/07/Overview-6.png -------------------------------------------------------------------------------- /src/main/moro/figures/07/Overview-7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/07/Overview-7.png -------------------------------------------------------------------------------- /src/main/moro/figures/07/flikr.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/07/flikr.png -------------------------------------------------------------------------------- /src/main/moro/figures/07/results.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/07/results.png -------------------------------------------------------------------------------- /src/main/moro/figures/07/subsample-wMAP.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/07/subsample-wMAP.png -------------------------------------------------------------------------------- /src/main/moro/figures/07/zero-shot-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/07/zero-shot-1.png -------------------------------------------------------------------------------- /src/main/moro/figures/07/zero-shot-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/07/zero-shot-2.png -------------------------------------------------------------------------------- /src/main/moro/figures/07/zero-shot-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/07/zero-shot-3.png -------------------------------------------------------------------------------- /src/main/moro/figures/07/zero-shot-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/07/zero-shot-4.png -------------------------------------------------------------------------------- /src/main/moro/figures/07/zero-shot-5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/07/zero-shot-5.png -------------------------------------------------------------------------------- /src/main/moro/figures/08/multitask.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/08/multitask.png -------------------------------------------------------------------------------- /src/main/moro/figures/08/parse_results.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/08/parse_results.png -------------------------------------------------------------------------------- /src/main/moro/figures/08/s8s1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/08/s8s1.png -------------------------------------------------------------------------------- /src/main/moro/figures/08/s8s10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/08/s8s10.png -------------------------------------------------------------------------------- /src/main/moro/figures/08/s8s11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/08/s8s11.png -------------------------------------------------------------------------------- /src/main/moro/figures/08/s8s2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/08/s8s2.png -------------------------------------------------------------------------------- /src/main/moro/figures/08/s8s3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/08/s8s3.png -------------------------------------------------------------------------------- /src/main/moro/figures/08/s8s4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/08/s8s4.png -------------------------------------------------------------------------------- /src/main/moro/figures/08/s8s5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/08/s8s5.png -------------------------------------------------------------------------------- /src/main/moro/figures/08/s8s6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/08/s8s6.png -------------------------------------------------------------------------------- /src/main/moro/figures/08/s8s7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/08/s8s7.png -------------------------------------------------------------------------------- /src/main/moro/figures/08/s8s8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/08/s8s8.png -------------------------------------------------------------------------------- /src/main/moro/figures/08/s8s9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/08/s8s9.png -------------------------------------------------------------------------------- /src/main/moro/figures/08/srl-results.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/08/srl-results.png -------------------------------------------------------------------------------- /src/main/moro/figures/09/hankel_grammar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/09/hankel_grammar.png -------------------------------------------------------------------------------- /src/main/moro/figures/09/make_hankel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/09/make_hankel.png -------------------------------------------------------------------------------- /src/main/moro/figures/4drubik.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/4drubik.png -------------------------------------------------------------------------------- /src/main/moro/figures/IntroToLDA.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/IntroToLDA.png -------------------------------------------------------------------------------- /src/main/moro/figures/KBP_MF_application.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/KBP_MF_application.png -------------------------------------------------------------------------------- /src/main/moro/figures/SVD.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/SVD.png -------------------------------------------------------------------------------- /src/main/moro/figures/SVDtrunc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/SVDtrunc.png -------------------------------------------------------------------------------- /src/main/moro/figures/ai/SVD.ai: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/ai/SVD.ai -------------------------------------------------------------------------------- /src/main/moro/figures/ai/SVD1.ai: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/ai/SVD1.ai -------------------------------------------------------------------------------- /src/main/moro/figures/ai/SVD2.ai: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/ai/SVD2.ai -------------------------------------------------------------------------------- /src/main/moro/figures/ai/fb_dm.ai: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/ai/fb_dm.ai -------------------------------------------------------------------------------- /src/main/moro/figures/ai/m-mult.ai: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/ai/m-mult.ai -------------------------------------------------------------------------------- /src/main/moro/figures/ai/mf.ai: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/ai/mf.ai -------------------------------------------------------------------------------- /src/main/moro/figures/ai/mf_apps.ai: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/ai/mf_apps.ai -------------------------------------------------------------------------------- /src/main/moro/figures/ai/nonSVD.ai: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/ai/nonSVD.ai -------------------------------------------------------------------------------- /src/main/moro/figures/ai/norm3.ai: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/ai/norm3.ai -------------------------------------------------------------------------------- /src/main/moro/figures/constrainedmf.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/constrainedmf.png -------------------------------------------------------------------------------- /src/main/moro/figures/fibers.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/fibers.png -------------------------------------------------------------------------------- /src/main/moro/figures/homer.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/homer.jpg -------------------------------------------------------------------------------- /src/main/moro/figures/identity.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/identity.png -------------------------------------------------------------------------------- /src/main/moro/figures/mf-neural.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/mf-neural.png -------------------------------------------------------------------------------- /src/main/moro/figures/mfprior.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/mfprior.png -------------------------------------------------------------------------------- /src/main/moro/figures/nickel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/nickel.png -------------------------------------------------------------------------------- /src/main/moro/figures/norm1of4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/norm1of4.png -------------------------------------------------------------------------------- /src/main/moro/figures/norm2of4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/norm2of4.png -------------------------------------------------------------------------------- /src/main/moro/figures/norm3of4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/norm3of4.png -------------------------------------------------------------------------------- /src/main/moro/figures/norm4of4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/norm4of4.png -------------------------------------------------------------------------------- /src/main/moro/figures/norms.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/norms.png -------------------------------------------------------------------------------- /src/main/moro/figures/omni/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/omni/.DS_Store -------------------------------------------------------------------------------- /src/main/moro/figures/omni/mf-neural.gstencil/image10.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/omni/mf-neural.gstencil/image10.pdf -------------------------------------------------------------------------------- /src/main/moro/figures/omni/mf-neural.gstencil/image13.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/omni/mf-neural.gstencil/image13.pdf -------------------------------------------------------------------------------- /src/main/moro/figures/omni/mf-neural.gstencil/image15.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/omni/mf-neural.gstencil/image15.pdf -------------------------------------------------------------------------------- /src/main/moro/figures/omni/mf-neural.gstencil/image2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/omni/mf-neural.gstencil/image2.pdf -------------------------------------------------------------------------------- /src/main/moro/figures/omni/mf-neural.gstencil/image3.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/omni/mf-neural.gstencil/image3.pdf -------------------------------------------------------------------------------- /src/main/moro/figures/omni/mf-neural.gstencil/image7.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/omni/mf-neural.gstencil/image7.pdf -------------------------------------------------------------------------------- /src/main/moro/figures/omni/mf-neural.gstencil/image8.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/omni/mf-neural.gstencil/image8.pdf -------------------------------------------------------------------------------- /src/main/moro/figures/omni/mf-neural.gstencil/image9.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/omni/mf-neural.gstencil/image9.pdf -------------------------------------------------------------------------------- /src/main/moro/figures/omni/rescal-neural.gstencil/image10.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/omni/rescal-neural.gstencil/image10.pdf -------------------------------------------------------------------------------- /src/main/moro/figures/omni/rescal-neural.gstencil/image13.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/omni/rescal-neural.gstencil/image13.pdf -------------------------------------------------------------------------------- /src/main/moro/figures/omni/rescal-neural.gstencil/image14.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/omni/rescal-neural.gstencil/image14.pdf -------------------------------------------------------------------------------- /src/main/moro/figures/omni/rescal-neural.gstencil/image17.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/omni/rescal-neural.gstencil/image17.pdf -------------------------------------------------------------------------------- /src/main/moro/figures/omni/rescal-neural.gstencil/image18.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/omni/rescal-neural.gstencil/image18.pdf -------------------------------------------------------------------------------- /src/main/moro/figures/omni/rescal-neural.gstencil/image19.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/omni/rescal-neural.gstencil/image19.pdf -------------------------------------------------------------------------------- /src/main/moro/figures/omni/rescal-neural.gstencil/image2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/omni/rescal-neural.gstencil/image2.pdf -------------------------------------------------------------------------------- /src/main/moro/figures/omni/rescal-neural.gstencil/image8.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/omni/rescal-neural.gstencil/image8.pdf -------------------------------------------------------------------------------- /src/main/moro/figures/omni/tf-mat.gstencil/image16.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/omni/tf-mat.gstencil/image16.pdf -------------------------------------------------------------------------------- /src/main/moro/figures/omni/tf-mat.gstencil/image17.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/omni/tf-mat.gstencil/image17.pdf -------------------------------------------------------------------------------- /src/main/moro/figures/omni/tf-matz.gstencil/image17.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/omni/tf-matz.gstencil/image17.pdf -------------------------------------------------------------------------------- /src/main/moro/figures/omni/tf-rank.gstencil/image17.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/omni/tf-rank.gstencil/image17.pdf -------------------------------------------------------------------------------- /src/main/moro/figures/omni/tf-vec.gstencil/image16.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/omni/tf-vec.gstencil/image16.pdf -------------------------------------------------------------------------------- /src/main/moro/figures/omni/tf-vec.gstencil/image17.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/omni/tf-vec.gstencil/image17.pdf -------------------------------------------------------------------------------- /src/main/moro/figures/readTheMatrix.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/readTheMatrix.png -------------------------------------------------------------------------------- /src/main/moro/figures/rescal-neural.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/rescal-neural.png -------------------------------------------------------------------------------- /src/main/moro/figures/rescal-results.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/rescal-results.png -------------------------------------------------------------------------------- /src/main/moro/figures/rescal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/rescal.png -------------------------------------------------------------------------------- /src/main/moro/figures/slices.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/slices.png -------------------------------------------------------------------------------- /src/main/moro/figures/tensor-ex.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/tensor-ex.png -------------------------------------------------------------------------------- /src/main/moro/figures/tf-mat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/tf-mat.png -------------------------------------------------------------------------------- /src/main/moro/figures/tf-matz.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/tf-matz.png -------------------------------------------------------------------------------- /src/main/moro/figures/tf-rank.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/tf-rank.png -------------------------------------------------------------------------------- /src/main/moro/figures/tf-vec.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/tf-vec.png -------------------------------------------------------------------------------- /src/main/moro/figures/tfmf.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/tfmf.png -------------------------------------------------------------------------------- /src/main/moro/figures/tucker1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/tucker1.png -------------------------------------------------------------------------------- /src/main/moro/figures/tucker2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/tucker2.png -------------------------------------------------------------------------------- /src/main/moro/figures/tucker3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/tucker3.png -------------------------------------------------------------------------------- /src/main/moro/figures/uschema-results.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/uschema-results.png -------------------------------------------------------------------------------- /src/main/moro/figures/van.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/van.png -------------------------------------------------------------------------------- /src/main/moro/figures/vanillaMF.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/src/main/moro/figures/vanillaMF.png -------------------------------------------------------------------------------- /src/main/moro/overview.json: -------------------------------------------------------------------------------- 1 | ../../../moro/public/docs/overview.json -------------------------------------------------------------------------------- /src/main/moro/test.json: -------------------------------------------------------------------------------- 1 | { 2 | "name" : "Test Notebook", 3 | "cells" : [ { 4 | "id" : 0, 5 | "compiler" : "section", 6 | "input" : { 7 | "sessionId" : null, 8 | "code" : "1", 9 | "extraFields" : { } 10 | } 11 | }, { 12 | "id" : 1, 13 | "compiler" : "markdown", 14 | "input" : { 15 | "sessionId" : null, 16 | "code" : "### Matrix Operations\n- the **inner product** is \\\\(\\langle u,v \\rangle := \\sum_{l=1}^L u_{l} v_l\\\\)\nwhere \\\\(u\\in\\Re^L\\\\) and \\\\(v\\in\\Re^L\\\\)", 17 | "extraFields" : { } 18 | } 19 | }, { 20 | "id" : 2, 21 | "compiler" : "html", 22 | "input" : { 23 | "sessionId" : null, 24 | "code" : "", 25 | "extraFields" : { } 26 | } 27 | }, { 28 | "id" : 3, 29 | "compiler" : "section", 30 | "input" : { 31 | "sessionId" : null, 32 | "code" : "2", 33 | "extraFields" : { } 34 | } 35 | }, { 36 | "id" : 4, 37 | "compiler" : "markdown", 38 | "input" : { 39 | "sessionId" : null, 40 | "code" : "###Matrix Demo ", 41 | "extraFields" : { } 42 | } 43 | }, { 44 | "id" : 5, 45 | "compiler" : "scala", 46 | "input" : { 47 | "sessionId" : null, 48 | "code" : "import uk.ac.ucl.cs.mr.acltutorial._\nimport MatrixRenderer._\n\nval layout = Layout(colHeaderSize=100, rowHeaderSize=100,ch=50, cw=50)\n\n// first matrix just one cell\nval m1 = Matrix(Seq(Cell(0,0,1.0)),Seq(RowLabel(0,\"row1\")),Seq(ColLabel(0,\"col1\")), Nil) \n\n// on the fly creation of a column embedding, i.e. a \nval col1Embedding = colEmbedding(0,2, Seq(1,2))\n\nval m2 = Matrix(Seq(Cell(1,0,1.0),Cell(1,1,\"Blah\")),Seq(RowLabel(1,\"row1\"),RowLabel(0,\"row2\")),Seq(ColLabel(1,\"col2\")), Seq(0),Seq(1)) + colEmbedding(0,2, Seq(1,2)) + colEmbedding(1,2, Seq(1,2)) + rowEmbedding(1,2,Seq(2,1))\n\n// stages/overlays/fragments (3 of them)\nval matrices = Seq(m1,m2,m2 + rowEmbedding(0,2,Seq(2,1)))\n\n\nMatrixRenderer.render(matrices,layout)", 49 | "extraFields" : { 50 | "aggregatedCells" : "[]" 51 | } 52 | } 53 | }, { 54 | "id" : 6, 55 | "compiler" : "markdown", 56 | "input" : { 57 | "sessionId" : null, 58 | "code" : "*bottom text*", 59 | "extraFields" : { } 60 | } 61 | } ], 62 | "config" : { } 63 | } 64 | -------------------------------------------------------------------------------- /src/main/scala/uk/ac/ucl/cs/mr/acltutorial/BinaryMF.scala: -------------------------------------------------------------------------------- 1 | package uk.ac.ucl.cs.mr.acltutorial 2 | 3 | import uk.ac.ucl.cs.mr.acltutorial.MatrixRenderer._ 4 | 5 | import scala.util.Random 6 | 7 | /** 8 | * @author riedelcastro 9 | */ 10 | object BinaryMF { 11 | 12 | val myRandom = new Random(0) 13 | 14 | def formatNumber(d: Double) = f"$d%2.2f" 15 | 16 | val persons = Seq("Anna", "Bob", "James", "Andreas") 17 | val organizations = Seq("UCL", "Oxford", "Sheffield", "MSR") 18 | 19 | val relations = Seq("worksFor", "lecturerAt", "professorAt", "studiedAt") 20 | 21 | val numPairs = 5 22 | 23 | val pairs = myRandom.shuffle(for (p <- persons; o <- organizations) yield (p, o)).take(numPairs) 24 | 25 | val randomGraph = 26 | for (row <- 0 until numPairs) yield for (col <- relations.indices) yield if (myRandom.nextDouble() < 0.3) 1.0 else 0.0 27 | 28 | def toCells(data: Seq[Seq[Double]], filter: Double => Boolean = _ => true) = 29 | for (row <- data.indices; col <- data(row).indices; value = data(row)(col)) 30 | yield Cell(row, col, if (filter(value)) value else "") 31 | 32 | def toRowLabels(rows: Seq[String]) = for (r <- rows.indices) yield RowLabel(r, rows(r)) 33 | 34 | def toColLabels(cols: Seq[String]) = for (r <- cols.indices) yield ColLabel(r, cols(r)) 35 | 36 | val allCells = Matrix(toCells(randomGraph), toRowLabels(pairs.map(_.toString())), toColLabels(relations)) 37 | 38 | val noZeroes = allCells.copy(cells = toCells(randomGraph, _ > 0.5)) 39 | 40 | val someSampledZeroes = allCells.copy(cells = toCells(randomGraph, v => v > 0.5 || myRandom.nextDouble() < 0.5)) 41 | 42 | val moreSampledZeroes = allCells.copy(cells = toCells(randomGraph, v => v > 0.5 || myRandom.nextDouble() < 0.8)) 43 | 44 | val uSchemaRels = Seq("X, professor at Y", "X teaches at Y", "professorAt", "workedAt") 45 | val uSchemaNoZeroes = allCells.copy(cells = 46 | toCells(randomGraph, _ > 0.5).map(c => if (c.col > 1) c.copy(value = "?") else c), colLabels = toColLabels(uSchemaRels)) 47 | 48 | 49 | val colEmbeddings = for (r <- relations.indices) yield Range(0, 2).map(_ => myRandom.nextGaussian()) 50 | val rowEmbeddings = for (r <- 0 until numPairs) yield Range(0, 2).map(_ => myRandom.nextGaussian()) 51 | 52 | def samplePositiveCell(data: Seq[Cell]): Cell = { 53 | val positive = data.collect { case c@Cell(_, _, 1.0,_,_,_,_) => c } 54 | positive(myRandom.nextInt(positive.length)) 55 | } 56 | 57 | def sgdWithNegativeSampling(matrix:Matrix) = { 58 | def iteration() = { 59 | val pos1 = samplePositiveCell(matrix.cells) 60 | val m1 = matrix.copy(cells = Seq(pos1)) + 61 | rowEmbedding(pos1.row, relations.length, rowEmbeddings(pos1.row).map(formatNumber)) + 62 | colEmbedding(pos1.col, numPairs, colEmbeddings(pos1.col).map(formatNumber)) 63 | val negInCol = matrix.cells.collect { case c@Cell(_, pos1.col, 0.0,_,_,_,_) => c } 64 | val neg1 = negInCol(myRandom.nextInt(negInCol.size)) 65 | val m2 = matrix.copy(cells = Seq(neg1)) + 66 | rowEmbedding(neg1.row, relations.length, rowEmbeddings(neg1.row).map(formatNumber)) + 67 | colEmbedding(neg1.col, numPairs, colEmbeddings(neg1.col).map(formatNumber)) 68 | Seq(m1, m2) 69 | } 70 | Seq(allCells) ++ iteration() ++ iteration() 71 | } 72 | 73 | val sgdUpdates = sgdWithNegativeSampling(allCells) 74 | 75 | def main(args: Array[String]) { 76 | 77 | } 78 | 79 | } 80 | -------------------------------------------------------------------------------- /src/main/scala/uk/ac/ucl/cs/mr/acltutorial/ManualCMF.scala: -------------------------------------------------------------------------------- 1 | package uk.ac.ucl.cs.mr.acltutorial 2 | 3 | import cc.factorie.la.{DenseTensor1, DenseTensor2} 4 | import ml.wolfe.{Mat, Vect} 5 | import uk.ac.ucl.cs.mr.acltutorial.MatrixRenderer.{Cell, ColLabel, Matrix, RowLabel} 6 | 7 | /** 8 | * @author gbouchar 9 | */ 10 | 11 | 12 | object ManualCMF { 13 | 14 | val logistic_type = 0 15 | val l2_type = 1 16 | val rand = new scala.util.Random(0) 17 | 18 | 19 | 20 | 21 | // sample a normalized discrete distribution 22 | def sample_discrete(probas: Seq[Double]): Int = { 23 | var mass = rand.nextDouble() - probas.head 24 | var pos = 0 25 | while (mass > 0 && pos < probas.length - 1){ 26 | pos += 1 27 | mass -= probas(pos) 28 | } 29 | pos 30 | } 31 | 32 | // computation of the model 33 | 34 | def initial_embeddings(N: Int, rank: Int, scale: Double = 0.1): Seq[DenseTensor1] = { 35 | val rand = new scala.util.Random(0) 36 | val U = for (i <- 0 until N) yield new DenseTensor1(rank) 37 | for (i <- (0 until N).toList; k <- (0 until rank).toList) { 38 | U(i)(k) = scale * rand.nextGaussian() 39 | } 40 | U 41 | } 42 | 43 | 44 | 45 | def loss_gradient(loss_type: Int, score:Double, gold:Double): Double = { 46 | var grad = 0.0 47 | if (loss_type == logistic_type) { 48 | val s = (2.0 * gold - 1.0) 49 | grad = s / (1.0 + math.exp( math.min(100.0, s * score))) 50 | //println("" + (gold,score, (2.0 * gold - 1.0) * score,grad)) 51 | }else if(loss_type == l2_type) { 52 | grad = score - gold 53 | } 54 | grad 55 | } 56 | 57 | // Sampling in a sequence 58 | type T = (Int, Int, Double) //todo: Make a generic type 59 | def sample_seq(S: Seq[T]): T = { 60 | S(rand.nextInt(S.length)) 61 | } 62 | 63 | case class Table( 64 | loss_type: Int, 65 | observations: Seq[(Int,Int,Double)]) 66 | 67 | def num_of_entities(list_of_tables: Seq[Table]): Int = { 68 | var N = 0 69 | for (table <- list_of_tables){ 70 | for ((i, j, v) <- table.observations){ 71 | if (i > N) N = i 72 | if (j > N) N = j 73 | } 74 | } 75 | N + 1 76 | } 77 | 78 | def optimizeCMF0(database: Seq[Table], tables_weights: Seq[Double], rk: Int, iters: Int, step_size:Double = 0.1, initScale:Double = 1.0): Seq[Vect] = { 79 | val U = initial_embeddings(num_of_entities(database), rk, initScale) // N*rank embedding matrix 80 | for (it <- 0 until iters) { // Loop over SGD iterations 81 | // Sampling an observation 82 | val relation = sample_discrete(tables_weights) 83 | val table = database(relation) 84 | val observation = sample_seq(table.observations) 85 | //Gradient Step 86 | val (i, j, gold) = observation 87 | val v1 = U(i).copy 88 | val v2 = U(j).copy 89 | val dloss = loss_gradient(table.loss_type, v1 dot v2, gold) 90 | // if (table.loss_type == logistic_type) { 91 | // println("dot=" + (v1 dot v2)) 92 | // println("gold=" + gold) 93 | // println("dloss=" + dloss) 94 | // } 95 | U(i) -= v2 * step_size * dloss 96 | U(j) -= v1 * step_size * dloss 97 | } 98 | U //output the embedding matrix} 99 | } 100 | 101 | 102 | 103 | 104 | 105 | def main(args: Array[String]) { 106 | // val n = 5 107 | // val m = 5 108 | // val M = new DenseTensor2(n, m) 109 | // val rand = new scala.util.Random(0) 110 | // 111 | // //this should be the data 112 | // for (i <- 0 until m; j <- 0 until m) { 113 | // M(i, j) = rand.nextGaussian() 114 | // } 115 | // val (_A, _V) = optimizeL2(M, 2, 10) 116 | val entityNames = Seq( 117 | Seq("Greece","Tsipras","Germany","crisis","economy"), 118 | Seq("Topic G","Topic P","Topic E"), 119 | Seq("D1","D2","D3","D4","D5")) 120 | 121 | val n1 = entityNames(0).length //number of entities of type 1 (words) 122 | val n2 = entityNames(1).length //number of entities of type 2 (labels) 123 | val n3 = entityNames(2).length //number of entities of type 1 (documents) 124 | 125 | val tuples31 = toTuples(parseMatrix( 126 | """1 2 0 0 0 127 | 0 0 1 0 0 128 | 0 0 0 1 1 129 | 0 0 1 1 1 130 | 1 2 1 1 1"""), n1 + n2, 0) 131 | 132 | val tuples32 = toTuples(parseMatrix( 133 | """1 0 0 134 | 0 1 1 135 | 0 1 1 136 | 0 1 0 137 | 1 0 1"""), n1 + n2, n1) 138 | 139 | val tuples21 = toTuples(parseMatrix( 140 | """1 1 0 0 0 141 | 1 1 0 1 1 142 | 1 1 1 1 1"""), n1, 0) 143 | /* 144 | val tuples31 = toTuples(parseMatrix( 145 | """1 2 0 0 0 146 | 0 0 0 0 0 147 | 0 0 1 1 1 148 | 0 0 1 1 1 149 | 1 2 1 1 1"""), n1 + n2, 0) 150 | 151 | val tuples32 = toTuples(parseMatrix( 152 | """1 0 0 153 | 0 0 0 154 | 0 1 1 155 | 0 1 1 156 | 1 1 1"""), n1 + n2, n1) 157 | 158 | val tuples21 = toTuples(parseMatrix( 159 | """1 1 0 0 0 160 | 1 1 1 1 1 161 | 1 1 1 1 1"""), n1, 0) 162 | */ 163 | 164 | val T1 = new Table(loss_type = l2_type, observations = tuples31) 165 | val T2 = new Table(loss_type = l2_type, observations = tuples32) 166 | val T3 = new Table(loss_type = l2_type, observations = tuples21) 167 | 168 | val U = optimizeCMF0(Seq(T1, T2, T3), Seq(.3, .3, .4), 1, 100000,.01,.001) 169 | println(dots(U,U)) 170 | //println(tuplesToMatrix(tuples21)) 171 | println("finished") 172 | 173 | 174 | } 175 | // utilities 176 | def tuplesToMatrix(tuples:Seq[(Int,Int,Double)]): Matrix = { 177 | val max_i = tuples.map(_._1).reduceLeft(math.max) + 1 178 | val min_i = tuples.map(_._1).reduceLeft(math.min) 179 | val max_j = tuples.map(_._2).reduceLeft(math.max) + 1 180 | val min_j = tuples.map(_._2).reduceLeft(math.min) 181 | val cells = for ((i, j, v) <- tuples) yield Cell(i - min_i, j - min_j, v) 182 | Matrix(cells) 183 | } 184 | 185 | def transpose(tuples:Seq[(Int,Int,Double)]) = { 186 | for ((i,j,v) <- tuples) yield (j,i,v) 187 | } 188 | 189 | 190 | //rendering functions 191 | 192 | 193 | def header(rows: Seq[String], cols: Seq[String]) = Matrix( 194 | rowLabels = rows.zipWithIndex map { case (r, i) => RowLabel(i, r) }, 195 | colLabels = cols.zipWithIndex map { case (r, i) => ColLabel(i, r) } 196 | ) 197 | 198 | 199 | 200 | def dotProductMatrix(A: Seq[Vect], V: Seq[Vect]) = { 201 | matrix(dots(A, V)) 202 | } 203 | 204 | def dots(A: Seq[Vect], V: Seq[Vect]) = { 205 | val M = new DenseTensor2(A.length, V.length) 206 | for (i <- (0 until M.dim1).toList; j <- (0 until M.dim2).toList) M(i, j) = A(i) dot V(j) 207 | M 208 | } 209 | 210 | 211 | 212 | def parseMatrix(string: String,offset_row: Int = 0, offset_col: Int = 0) = { 213 | val rows = string.split("\n").map(_.trim.split("\\s")) 214 | val n = rows.length + offset_row 215 | val m = rows.head.length + offset_col 216 | val mat = new DenseTensor2(n, m) 217 | for (i <- 0 until n; j <- 0 until m) mat(i + offset_row, j + offset_col) = rows(i)(j).toDouble 218 | mat 219 | } 220 | 221 | def toTuples(mat: DenseTensor2, offset_row: Int = 0, offset_col: Int = 0): Seq[(Int, Int, Double)] = { 222 | val S = Range(0,mat.dim1) flatMap(i => Range(0,mat.dim2).map( 223 | j => (i + offset_row, j + offset_col, mat(i,j)))) 224 | S 225 | } 226 | 227 | def delta(m1: Mat, m2: Mat) = { 228 | val result = new DenseTensor2(m1.dim1, m1.dim2) 229 | for (i <- 0 until m1.dim1; j <- 0 until m1.dim2) 230 | result(i, j) = m1(i, j) - m2(i, j) 231 | result 232 | } 233 | 234 | 235 | 236 | 237 | 238 | // rendering functions 239 | import MatrixRenderer._ 240 | 241 | 242 | def matrix(M: Mat) = { 243 | Matrix(for (i <- (0 until M.dim1).toList; j <- (0 until M.dim2).toList) yield Cell(i, j, M(i, j))) 244 | } 245 | 246 | def colVector(v: Vect) = { 247 | Matrix(for (i <- 0 until v.dim1) yield Cell(i, 0, v(i))) 248 | } 249 | 250 | def rowVector(v: Vect) = { 251 | Matrix(for (i <- 0 until v.dim1) yield Cell(0, i, v(i))) 252 | } 253 | 254 | def numbers(m: Matrix) = { 255 | m.copy(m.cells collect { case cell@Cell(_, _, d: Double, _, _, _, _) => cell.copy(value = f"$d%2.2f") }) 256 | } 257 | 258 | def parseRenderMatrix(string: String) = { 259 | val rows = string.split("\n").map(_.trim.split("\\s")) 260 | val n = rows.length 261 | val m = rows.head.length 262 | val cells = for (i <- 0 until n; j <- 0 until m; if rows(i)(j) != "_") yield Cell(i, j, rows(i)(j)) 263 | Matrix(cells) 264 | } 265 | 266 | def sigm(mat: Mat) = { 267 | val result = new DenseTensor2(mat.dim1, mat.dim2) 268 | for (i <- 0 until mat.dim1; j <- 0 until mat.dim2) 269 | result(i, j) = ml.wolfe.util.Math.sigmoid(mat(i, j)) 270 | result 271 | } 272 | 273 | def l2Loss(guess: Mat, gold: Mat) = { 274 | guess.l2Similarity(gold) 275 | } 276 | 277 | def embeddings(A: Seq[Vect], V: Seq[Vect], withBoxes: Boolean = false): Matrix = { 278 | val rows = A.length 279 | val cols = V.length 280 | val plusRowEmbeddings = A.indices.map(i => rowEmbedding(i, cols, A(i).toSeq, withBoxes)).foldLeft(Matrix())(_ + _) 281 | val plusColEmbeddings = V.indices.map(j => colEmbedding(j, rows, V(j).toSeq, withBoxes)).foldLeft(plusRowEmbeddings)(_ + _) 282 | plusColEmbeddings.copy(hRulers = Seq(rows), vRulers = Seq(cols)) 283 | } 284 | 285 | 286 | def toEmbeddings(u: Mat, s: Vect, v: Mat, k: Int): (Seq[Vect], Seq[Vect]) = { 287 | val _a = for (i <- 0 until u.dim1) yield new DenseTensor1(k) 288 | val _v = for (i <- 0 until v.dim1) yield new DenseTensor1(k) 289 | for (i <- _a.indices; l <- 0 until k) _a(i)(l) = u(i, l) * math.sqrt(s(l)) 290 | for (j <- _v.indices; l <- 0 until k) _v(j)(l) = v(l, j) * math.sqrt(s(l)) 291 | (_a, _v) 292 | } 293 | 294 | 295 | } 296 | -------------------------------------------------------------------------------- /src/main/scala/uk/ac/ucl/cs/mr/acltutorial/ManualMF.scala: -------------------------------------------------------------------------------- 1 | package uk.ac.ucl.cs.mr.acltutorial 2 | 3 | import breeze.linalg.{svd, DenseMatrix} 4 | import cc.factorie.la.{DenseTensor2, DenseTensor1} 5 | import ml.wolfe.{Mat, Vect} 6 | import ml.wolfe.term.{IntTerm, domain} 7 | import uk.ac.ucl.cs.mr.acltutorial.MatrixRenderer.{ColLabel, RowLabel, Cell, Matrix} 8 | 9 | /** 10 | * @author riedelcastro 11 | */ 12 | object ManualMF { 13 | 14 | 15 | def initialAV(K: Int, n: Int, m: Int, scale: Double = 0.1) = { 16 | val rand = new scala.util.Random(0) 17 | val A = for (i <- 0 until n) yield new DenseTensor1(K) 18 | val V = for (j <- 0 until m) yield new DenseTensor1(K) 19 | for (i <- (0 until n).toList; k <- (0 until K).toList) { 20 | A(i)(k) = scale * rand.nextGaussian() 21 | } 22 | 23 | for (j <- (0 until m).toList; k <- (0 until K).toList) { 24 | V(j)(k) = scale * rand.nextGaussian() 25 | } 26 | (A, V) 27 | } 28 | 29 | def header(rows: Seq[String], cols: Seq[String]) = Matrix( 30 | rowLabels = rows.zipWithIndex map { case (r, i) => RowLabel(i, r) }, 31 | colLabels = cols.zipWithIndex map { case (r, i) => ColLabel(i, r) } 32 | ) 33 | 34 | def optimizeL2(M: Mat, K: Int, iterations: Int): (Seq[Vect], Seq[Vect]) = { 35 | val rand = new scala.util.Random(0) 36 | 37 | val n = M.dim1 38 | val m = M.dim2 39 | 40 | val alpha = 0.1 41 | val AV = initialAV(K, n, m) 42 | val A = AV._1 43 | val V = AV._2 44 | 45 | def update(i: Int, j: Int): Unit = { 46 | val a = A(i).copy 47 | val v = V(j).copy 48 | val y = a dot v 49 | A(i) += v * alpha * (M(i, j) - y) 50 | V(j) += a * alpha * (M(i, j) - y) 51 | } 52 | 53 | for (_ <- (0 until iterations).toList) { 54 | val i = rand.nextInt(n) 55 | val j = rand.nextInt(m) 56 | update(i, j) 57 | } 58 | (A, V) 59 | } 60 | 61 | 62 | import MatrixRenderer._ 63 | 64 | def dotProductMatrix(A: Seq[Vect], V: Seq[Vect]) = { 65 | matrix(dots(A, V)) 66 | } 67 | 68 | def dots(A: Seq[Vect], V: Seq[Vect]) = { 69 | val M = new DenseTensor2(A.length, V.length) 70 | for (i <- (0 until M.dim1).toList; j <- (0 until M.dim2).toList) M(i, j) = A(i) dot V(j) 71 | M 72 | } 73 | 74 | def delta(m1: Mat, m2: Mat) = { 75 | val result = new DenseTensor2(m1.dim1, m1.dim2) 76 | for (i <- 0 until m1.dim1; j <- 0 until m1.dim2) 77 | result(i, j) = m1(i, j) - m2(i, j) 78 | result 79 | } 80 | 81 | def matrix(M: Mat) = { 82 | Matrix(for (i <- (0 until M.dim1).toList; j <- (0 until M.dim2).toList) yield Cell(i, j, M(i, j))) 83 | } 84 | 85 | def colVector(v: Vect) = { 86 | Matrix(for (i <- 0 until v.dim1) yield Cell(i, 0, v(i))) 87 | } 88 | 89 | def rowVector(v: Vect) = { 90 | Matrix(for (i <- 0 until v.dim1) yield Cell(0, i, v(i))) 91 | } 92 | 93 | def numbers(m: Matrix) = { 94 | m.copy(m.cells collect { case cell@Cell(_, _, d: Double, _, _, _, _) => cell.copy(value = f"$d%2.2f") }) 95 | } 96 | 97 | def opacity(m: Matrix, min: Double = -1, max: Double = 1, color: (Int, Int, Int) = (0, 0, 0)) = { 98 | def valueToOpacity(value: Double) = { 99 | val capped = Math.min(Math.max(min, value), max) 100 | (capped - min) / (max - min) 101 | } 102 | m.copy(m.cells collect { case cell@Cell(_, _, d: Double, _, _, _, _) => 103 | cell.copy(value = "", color = color, opacity = valueToOpacity(d)) 104 | }) 105 | } 106 | 107 | def parseMatrix(string: String) = { 108 | val rows = string.split("\n").map(_.trim.split("\\s")) 109 | val n = rows.length 110 | val m = rows.head.length 111 | val mat = new DenseTensor2(n, m) 112 | for (i <- 0 until n; j <- 0 until m) mat(i, j) = rows(i)(j).toDouble 113 | mat 114 | } 115 | 116 | def parseRenderMatrix(string: String) = { 117 | val rows = string.split("\n").map(_.trim.split("\\s")) 118 | val n = rows.length 119 | val m = rows.head.length 120 | val cells = for (i <- 0 until n; j <- 0 until m; if rows(i)(j) != "_") yield Cell(i, j, rows(i)(j)) 121 | Matrix(cells) 122 | } 123 | 124 | def sigm(mat: Mat) = { 125 | val result = new DenseTensor2(mat.dim1, mat.dim2) 126 | for (i <- 0 until mat.dim1; j <- 0 until mat.dim2) 127 | result(i, j) = ml.wolfe.util.Math.sigmoid(mat(i, j)) 128 | result 129 | } 130 | 131 | def l2Loss(guess: Mat, gold: Mat) = { 132 | guess.l2Similarity(gold) 133 | } 134 | 135 | def embeddings(A: Seq[Vect], V: Seq[Vect], withBoxes: Boolean = false): Matrix = { 136 | val rows = A.length 137 | val cols = V.length 138 | val plusRowEmbeddings = A.indices.map(i => rowEmbedding(i, cols, A(i).toSeq, withBoxes)).foldLeft(Matrix())(_ + _) 139 | val plusColEmbeddings = V.indices.map(j => colEmbedding(j, rows, V(j).toSeq, withBoxes)).foldLeft(plusRowEmbeddings)(_ + _) 140 | plusColEmbeddings.copy(hRulers = Seq(rows), vRulers = Seq(cols)) 141 | } 142 | 143 | def breezeSVD(mat: Mat): (Mat, Vect, Mat) = { 144 | val asBreeze = toBreezeMat(mat) 145 | val (u, s, v) = svd(asBreeze) 146 | (toFactorieMat(u), new DenseTensor1(s.toArray), toFactorieMat(v)) 147 | } 148 | 149 | def toEmbeddings(u: Mat, s: Vect, v: Mat, k: Int): (Seq[Vect], Seq[Vect]) = { 150 | val _a = for (i <- 0 until u.dim1) yield new DenseTensor1(k) 151 | val _v = for (i <- 0 until v.dim1) yield new DenseTensor1(k) 152 | for (i <- _a.indices; l <- 0 until k) _a(i)(l) = u(i, l) * math.sqrt(s(l)) 153 | for (j <- _v.indices; l <- 0 until k) _v(j)(l) = v(l, j) * math.sqrt(s(l)) 154 | (_a, _v) 155 | } 156 | 157 | def toBreezeMat(mat: Mat) = { 158 | DenseMatrix.create(mat.dim1, mat.dim2, mat.toArray).t 159 | } 160 | 161 | def toFactorieMat(mat: DenseMatrix[Double]) = { 162 | val result = new DenseTensor2(mat.rows, mat.cols) 163 | for (i <- 0 until mat.rows; j <- 0 until mat.cols) result(i, j) = mat(i, j) 164 | result 165 | } 166 | 167 | def nmf(mat: Mat, k: Int, iterations: Int) = { 168 | val Y = toBreezeMat(mat) 169 | val YY = Y * Y.t 170 | val W = DenseMatrix.ones[Double](Y.rows, k) 171 | val H = DenseMatrix.ones[Double](k, Y.cols) 172 | 173 | for (_ <- 0 until iterations) { 174 | for (l <- 0 until k) { 175 | for (j <- 0 until Y.cols) { 176 | //get expected counts of "word" j in "topic" l, using observed doc-word matrix 177 | val observed = W(::, l) dot Y(::, j) 178 | //get expected counts of "word" j in "topic" l, using reconstructed doc-word matrix 179 | val reconstructed = W(::, l) dot (W * H(::, j)) //second term reconstructs word column using "word embeddings" 180 | H(l, j) = H(l, j) * observed / reconstructed 181 | } 182 | for (i <- 0 until Y.rows) { 183 | //get expected counts of "topic" l in "doc" i , using observed doc-word matrix 184 | val observed = H(l, ::).t dot Y(i, ::).t //dot Y(i, ::) 185 | //get expected counts of "word" j in "topic" l, using reconstructed doc-word matrix 186 | val reconstructed = H(l, ::).t dot (W(i, ::) * H).t 187 | W(i, l) = W(i, l) * observed / reconstructed 188 | } 189 | } 190 | } 191 | val a = for (i <- 0 until Y.rows) yield new DenseTensor1(W(i, ::).inner.toArray) 192 | val v = for (j <- 0 until Y.cols) yield new DenseTensor1(H(::, j).toArray) 193 | (a,v) 194 | } 195 | 196 | def main(args: Array[String]) { 197 | // val n = 5 198 | // val m = 5 199 | // val M = new DenseTensor2(n, m) 200 | // val rand = new scala.util.Random(0) 201 | // 202 | // //this should be the data 203 | // for (i <- 0 until m; j <- 0 until m) { 204 | // M(i, j) = rand.nextGaussian() 205 | // } 206 | // val (_A, _V) = optimizeL2(M, 2, 10) 207 | 208 | val M = parseMatrix( 209 | """1 2 0 0 0 210 | 0 0 1 0 0 211 | 0 0 0 1 1 212 | 0 0 1 1 1 213 | 1 2 1 1 1""") 214 | val m = toBreezeMat(M) 215 | 216 | val (u, s, v) = breezeSVD(M) 217 | println(s) 218 | 219 | val (_a, _v) = toEmbeddings(u, s, v, 4) 220 | println(dots(_a, _v)) 221 | 222 | val (nmf_a, nmf_v) = nmf(M,3,10) 223 | println(dots(nmf_a, nmf_v)) 224 | 225 | println(nmf_a) 226 | println(nmf_v) 227 | 228 | 229 | // 230 | // println(m) 231 | // println(toFactorieMat(m)) 232 | // 233 | // val bM = DenseMatrix((1.0,2.0), (2.0,4.0)) 234 | // val (u,s,v) = svd(bM) 235 | // println(s) 236 | 237 | } 238 | 239 | } 240 | -------------------------------------------------------------------------------- /src/main/scala/uk/ac/ucl/cs/mr/acltutorial/Renderer.scala: -------------------------------------------------------------------------------- 1 | package uk.ac.ucl.cs.mr.acltutorial 2 | 3 | import ml.wolfe.Vect 4 | import org.sameersingh.htmlgen.Custom.Vectors 5 | import org.sameersingh.htmlgen.{D3jsConverter, RawHTML, HTML} 6 | 7 | import scala.xml.{Unparsed, XML, PrettyPrinter} 8 | 9 | /** 10 | * @author riedelcastro 11 | */ 12 | object Renderer { 13 | 14 | def fragments(htmls: Seq[HTML], startIndex: Int = 0) = { 15 | val printer = new PrettyPrinter(0, 2) 16 | 17 | require(htmls.nonEmpty) 18 | val html =
19 |
20 | {Unparsed(htmls.head.source)} 21 |
{for (i <- 1 until htmls.length) yield 22 |
24 | {Unparsed(htmls(i).source)} 25 |
} 26 |
27 | RawHTML(printer.format(html)) 28 | } 29 | 30 | def floatLeft(htmls: Seq[HTML]) = { 31 | val printer = new PrettyPrinter(0, 2) 32 | val html = 33 |
34 | {for (html <- htmls) yield
{Unparsed(html.source)}
} 35 |
36 | RawHTML(printer.format(html)) 37 | } 38 | 39 | def points(data:(Seq[Vect],Seq[String])*) = { 40 | val vectors = for (((vectors,names),i) <- data.zipWithIndex; (v,n) <- vectors zip names) yield (i,n,v.toSeq) 41 | println("POINTS Output") 42 | println(vectors.length) 43 | println(vectors.mkString("\n")) 44 | D3jsConverter.convert(Vectors(vectors).norm) 45 | } 46 | 47 | 48 | } 49 | -------------------------------------------------------------------------------- /tutorial.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/tutorial.pdf -------------------------------------------------------------------------------- /tutorial_2up.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/acl2015tutorial/d92a14660ddde7fdbcfe7b6efb1fa9ecb62dfd2a/tutorial_2up.pdf --------------------------------------------------------------------------------