See https://github.com/romainl/vim-devdocs for an up-to-date version.
Look up keywords on https://devdocs.io from Vim
Use :DD without argument to look up the word under the cursor, scoped with the current filetype:
See https://github.com/romainl/vim-devdocs for an up-to-date version.
Use :DD without argument to look up the word under the cursor, scoped with the current filetype:
The fundamental unit in PyTorch is the Tensor. This post will serve as an overview for how we implement Tensors in PyTorch, such that the user can interact with it from the Python shell. In particular, we want to answer four main questions:
PyTorch defines a new package torch. In this post we will consider the ._C module. This module is known as an "extension module" - a Python module written in C. Such modules allow us to define new built-in object types (e.g. the Tensor) and to call C/C++ functions.
| import numpy as np | |
| import time | |
| import cv2 | |
| from direct.showbase.ShowBase import ShowBase | |
| from panda3d.core import FrameBufferProperties, WindowProperties | |
| from panda3d.core import GraphicsPipe, GraphicsOutput | |
| from panda3d.core import Texture | |
| from panda3d.core import loadPrcFileData | |
| loadPrcFileData('', 'show-frame-rate-meter true') |
| """ Trains an agent with (stochastic) Policy Gradients on Pong. Uses OpenAI Gym. """ | |
| import numpy as np | |
| import cPickle as pickle | |
| import gym | |
| # hyperparameters | |
| H = 200 # number of hidden layer neurons | |
| batch_size = 10 # every how many episodes to do a param update? | |
| learning_rate = 1e-4 | |
| gamma = 0.99 # discount factor for reward |
| #define let(name,value) const __typeof__ (value) name = value; | |
| #define var(name,value) __typeof__ (value) name = value; | |
| int main(int argc, char *argv[]) { | |
| let(x,3); // const int x = 3; | |
| var(y,5); // int y = 5; | |
| printf("x:%i y:%i",x,y); // -> x:3 y:5 | |
| } |
| """ | |
| This is a batched LSTM forward and backward pass | |
| """ | |
| import numpy as np | |
| import code | |
| class LSTM: | |
| @staticmethod | |
| def init(input_size, hidden_size, fancy_forget_bias_init = 3): |
Cython has two major benefits:
Cython gains most of it's benefit from statically typing arguments. However, statically typing is not required, in fact, regular python code is valid cython (but don't expect much of a speed up). By incrementally adding more type information, the code can speed up by several factors. This gist just provides a very basic usage of cython.
A lot of math grad school is reading books and papers and trying to understand what's going on. The difficulty is that reading math is not like reading a mystery thriller, and it's not even like reading a history book or a New York Times article.
The main issue is that, by the time you get to the frontiers of math, the words to describe the concepts don't really exist yet. Communicating these ideas is a bit like trying to explain a vacuum cleaner to someone who has never seen one, except you're only allowed to use words that are four letters long or shorter.
What can you say?