{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "You can read an overview of this Numerical Linear Algebra course in [this blog post](http://www.fast.ai/2017/07/17/num-lin-alg/). The course was originally taught in the [University of San Francisco MS in Analytics](https://www.usfca.edu/arts-sciences/graduate-programs/analytics) graduate program. Course lecture videos are [available on YouTube](https://www.youtube.com/playlist?list=PLtmWHNX-gukIc92m1K0P6bIOnZb-mg0hY) (note that the notebook numbers and video numbers do not line up, since some notebooks took longer than 1 video to cover).\n", "\n", "You can ask questions about the course on [our fast.ai forums](http://forums.fast.ai/c/lin-alg)." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# 0. Course Logistics" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Ask Questions" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Let me know how things are going. This is particularly important since I'm new to MSAN, I don't know everything you've seen/haven't seen." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Intro" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**My background and linear algebra love**:\n", "\n", "- **Swarthmore College**: linear algebra convinced me to be a math major! (minors in CS & linguistics) I thought linear algebra was beautiful, but theoretical\n", "- **Duke University**: Math PhD. Took numerical linear algebra. Enjoyed the course, but not my focus\n", "- **Research Triangle Institute**: first time using linear algebra in practice (healthcare economics, markov chains)\n", "- **Quant**: first time working with lots of data, decided to become a data scientist\n", "- **Uber**: data scientist\n", "- **Hackbright**: taught software engineering. Overhauled ML and collaborative filtering lectures\n", "- **fast.ai**: co-founded to make deep learning more accessible. Deep Learning involves a TON of linear algebra" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Teaching" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Teaching Approach**\n", "\n", "I'll be using a *top-down* teaching method, which is different from how most math courses operate. Typically, in a *bottom-up* approach, you first learn all the separate components you will be using, and then you gradually build them up into more complex structures. The problems with this are that students often lose motivation, don't have a sense of the \"big picture\", and don't know what they'll need.\n", "\n", "If you took the fast.ai deep learning course, that is what we used. You can hear more about my teaching philosophy [in this blog post](http://www.fast.ai/2016/10/08/teaching-philosophy/) or [in this talk](https://vimeo.com/214233053).\n", "\n", "Harvard Professor David Perkins has a book, [Making Learning Whole](https://www.amazon.com/Making-Learning-Whole-Principles-Transform/dp/0470633719) in which he uses baseball as an analogy. We don't require kids to memorize all the rules of baseball and understand all the technical details before we let them play the game. Rather, they start playing with a just general sense of it, and then gradually learn more rules/details as time goes on.\n", "\n", "All that to say, don't worry if you don't understand everything at first! You're not supposed to. We will start using some \"black boxes\" or matrix decompositions that haven't yet been explained, and then we'll dig into the lower level details later.\n", "\n", "To start, focus on what things DO, not what they ARE." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "People learn by:\n", "1. **doing** (coding and building)\n", "2. **explaining** what they've learned (by writing or helping others)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Text Book**\n", "\n", "The book [**Numerical Linear Algebra**](https://www.amazon.com/Numerical-Linear-Algebra-Lloyd-Trefethen/dp/0898713617) by Trefethen and Bau is recommended. The MSAN program has a few copies on hand.\n", "\n", "A secondary book is [**Numerical Methods**](https://www.amazon.com/Numerical-Methods-Analysis-Implementation-Algorithms/dp/0691151229) by Greenbaum and Chartier." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Basics" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Office hours**: 2:00-4:00 on Friday afternoons. Email me if you need to meet at other times.\n", "\n", "My contact info: **rachel@fast.ai**\n", "\n", "Class Slack: #numerical_lin_alg\n", "\n", "Email me if you will need to miss class.\n", "\n", "Jupyter Notebooks will be available on Github at: https://github.com/fastai/numerical-linear-algebra Please pull/download before class. **Some parts are removed for you to fill in as you follow along in class**. Be sure to let me know **THIS WEEK** if you are having any problems running the notebooks from your own computer. You may want to make a separate copy, because running Jupyter notebooks causes them to change, which can create github conflicts the next time you pull." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Check that you have MathJax running (which renders LaTeX, used for math equations) by running the following cell:" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "$$ e^{\\theta i} = \\cos(\\theta) + i \\sin(\\theta)$$ " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "check that you can import:" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": true }, "outputs": [], "source": [ "import numpy as np\n", "import sklearn" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Grading Rubric**:\n", "\n", "| Assignment | Percent |\n", "|-------------------|:-------:|\n", "| Attendance | 10% |\n", "| Homework | 20% |\n", "| Writing: proposal | 10% |\n", "| Writing: draft | 15% |\n", "| Writing: final | 15% |\n", "| Final Exam | 30% |" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Honor Code** \n", "\n", "No cheating nor plagiarism is allowed, please see below for more details." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**On Laptops**\n", "\n", "I ask you to be respectful of me and your classmates and to refrain from surfing the web or using social media (facebook, twitter, etc) or messaging programs during class. It is absolutely forbidden to use instant messaging programs, email, etc. during class lectures or quizzes." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Syllabus" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Topics Covered:\n", "\n", "1\\. Why are we here?\n", " - Matrix and Tensor Products\n", " - Matrix Decompositions\n", " - Accuracy\n", " - Memory use\n", " - Speed\n", " - Parallelization & Vectorization\n", "\n", "\n", "2\\. Topic Modeling with NMF and SVD\n", " - Topic Frequency-Inverse Document Frequency (TF-IDF)\n", " - Singular Value Decomposition (SVD)\n", " - Non-negative Matrix Factorization (NMF)\n", " - Stochastic Gradient Descent (SGD)\n", " - Intro to PyTorch\n", " - Truncated SVD, Randomized SVD\n", "\n", "\n", "3\\. Background Removal with Robust PCA\n", " - Robust PCA\n", " - Randomized SVD\n", " - LU factorization\n", "\n", "\n", "4\\. Compressed Sensing for CT scans with Robust Regression\n", " - L1 regularization\n", "\n", "\n", "5\\. Predicting Health Outcomes with Linear Regression\n", " - Linear regression\n", " - Polynomial Features\n", " - Speeding up with Numba\n", " - Regularization and Noise\n", " - Implementing linear regression 4 ways\n", "\n", "\n", "6\\. PageRank with Eigen Decompositions\n", " - Power Method\n", " - QR Algorithm\n", " - Arnoldi Iteration\n", "\n", "\n", "7\\. QR Factorization\n", " - Gram-Schmidt\n", " - Householder\n", " - Stability" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Writing Assignment" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Writing Assignment:** Writing about technical concepts is a hugely valuable skill. I want you to write a technical blog post related to numerical linear algebra. [A blog is like a resume, only better](http://www.fast.ai/2017/04/06/alternatives/). Technical writing is also important in creating documentation, sharing your work with co-workers, applying to speak at conferences, and practicing for interviews. (You don't actually have to publish it, although I hope you do, and please send me the link if you do.)\n", "- [List of ideas here](Project_ideas.txt)\n", "- Always cite sources, use quote marks around quotes. Do this even as you are first gathering sources and taking notes. If you plagiarize parts of someone else's work, you will fail.\n", "- Can be done in a Jupyter Notebook (Jupyter Notebooks can be turned into blog posts) or a [Kaggle Kernel](https://www.kaggle.com/xenocide/content-based-anime-recommender)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "For the proposal, write a brief paragraph about the problem/topic/experiment you plan to research/test and write about. You need to include **4 sources** that you plan to use: these can include Trefethen, other blog posts, papers, or books. Include a sentence about each source, stating what it's in it.\n", "\n", "Feel free to ask me if you are wondering if your topic idea is suitable!" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Excellent Technical Blogs\n", "\n", "Examples of great technical blog posts:\n", "- [Peter Norvig](http://nbviewer.jupyter.org/url/norvig.com/ipython/ProbabilityParadox.ipynb) (more [here](http://norvig.com/ipython/))\n", "- [Stephen Merity](https://smerity.com/articles/2017/deepcoder_and_ai_hype.html)\n", "- [Julia Evans](https://codewords.recurse.com/issues/five/why-do-neural-networks-think-a-panda-is-a-vulture) (more [here](https://jvns.ca/blog/2014/08/12/what-happens-if-you-write-a-tcp-stack-in-python/))\n", "- [Julia Ferraioli](http://blog.juliaferraioli.com/2016/02/exploring-world-using-vision-twilio.html)\n", "- [Edwin Chen](http://blog.echen.me/2014/10/07/moving-beyond-ctr-better-recommendations-through-human-evaluation/)\n", "- [Slav Ivanov](https://blog.slavv.com/picking-an-optimizer-for-style-transfer-86e7b8cba84b)\n", "- [Brad Kenstler](https://hackernoon.com/non-artistic-style-transfer-or-how-to-draw-kanye-using-captain-picards-face-c4a50256b814)\n", "- find [more on twitter](https://twitter.com/math_rachel)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Deadlines" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "| Assignment | Dates |\n", "|-------------------|:--------:|\n", "| Homeworks | TBA |\n", "| Writing: proposal | 5/30 |\n", "| Writing: draft | 6/15 |\n", "| Writing: final | 6/27 |\n", "| Final Exam | 6/29 |" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Linear Algebra" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We will review some linear algebra in class. However, if you find there are concepts you feel rusty on, you may want to review on your own. Here are some resources:\n", "\n", "- [3Blue1Brown Essence of Linear Algebra](https://www.youtube.com/playlist?list=PLZHQObOWTQDPD3MizzM2xVFitgF8hE_ab) videos about *geometric intuition* (fantastic! gorgeous!)\n", "- Lectures 1-6 of Trefethen\n", "- [Immersive linear algebra](http://immersivemath.com/ila/) free online textbook with interactive graphics\n", "- [Chapter 2](http://www.deeplearningbook.org/contents/linear_algebra.html) of Ian Goodfellow's Deep Learning Book\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## USF Policies" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Academic Integrity** \n", "\n", "USF upholds the standards of honesty and integrity from all members of the academic community. All students are expected to know and adhere to the University’s Honor Code. You can find the full text of the [code online](www.usfca.edu/academic_integrity). The policy covers:\n", "- Plagiarism: intentionally or unintentionally representing the words or ideas of another person as your own; failure to properly cite references; manufacturing references.\n", "- Working with another person when independent work is required.\n", "- Submission of the same paper in more than one course without the specific permission of each instructor.\n", "- Submitting a paper written (entirely or even a small part) by another person or obtained from the internet.\n", "- Plagiarism is plagiarism: it does not matter if the source being copied is on the Internet, from a book or textbook, or from quizzes or problem sets written up by other students.\n", "- The penalties for violation of the policy may include a failing grade on the assignment, a failing grade in the course, and/or a referral to the Academic Integrity Committee." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Students with Disabilities**\n", "\n", "If you are a student with a disability or disabling condition, or if you think you may have a disability, please contact USF Student Disability Services (SDS) at 415 422-2613 within the first week of class, or immediately upon onset of disability, to speak with a disability specialist. If you are determined eligible for reasonable accommodations, please meet with your disability specialist so they can arrange to have your accommodation letter sent to me, and we will discuss your needs for this course. For more information, please visit [this website]( http://www.usfca.edu/sds) or call (415) 422-2613." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Behavioral Expectations**\n", "\n", "All students are expected to behave in accordance with the [Student Conduct Code and other University policies](https://myusf.usfca.edu/fogcutter). Open discussion and disagreement is encouraged when done respectfully and in the spirit of academic discourse. There are also a variety of behaviors that, while not against a specific University policy, may create disruption in this course. Students whose behavior is disruptive or who fail to comply with the instructor may be dismissed from the class for the remainder of the class period and may need to meet with the instructor or Dean prior to returning to the next class period. If necessary, referrals may also be made to the Student Conduct process for violations of the Student Conduct Code." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Counseling and Psychological Services**\n", "\n", "Our diverse staff offers brief individual, couple, and group counseling to student members of our community. CAPS services are confidential and free of charge. Call 415-422-6352 for an initial consultation appointment. Having a crisis at 3 AM? We are still here for you. Telephone consultation through CAPS After Hours is available between the hours of 5:00 PM to 8:30 AM; call the above number and press 2." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Confidentiality, Mandatory Reporting, and Sexual Assault**\n", "\n", "As an instructor, one of my responsibilities is to help create a safe learning environment on our campus. I also have a mandatory reporting responsibility related to my role as a faculty member. I am required to share information regarding sexual misconduct or information about a crime that may have occurred on USFs campus with the University. Here are other resources:\n", "\n", "- To report any sexual misconduct, students may visit Anna Bartkowski (UC 5th floor) or see many other options by visiting [this website](https://myusf.usfca.edu/title-IX)\n", "- Students may speak to someone confidentially, or report a sexual assault confidentially by contacting Counseling and Psychological Services at 415-422-6352\n", "- To find out more about reporting a sexual assault at USF, visit [USF’s Callisto website](https://usfca.callistocampus.org/)\n", "- For an off-campus resource, contact [San Francisco Women Against Rape](http://www.sfwar.org/about.html) 415-647-7273" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.1" } }, "nbformat": 4, "nbformat_minor": 2 }