This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import numpy as np | |
| def softmax(x, axis=0): | |
| """ Calculate softmax function for an array x | |
| axis=0 calculates softmax across rows which means each column sums to 1 | |
| axis=1 calculates softmax across columns which means each row sums to 1 | |
| """ | |
| return np.exp(x) / np.expand_dims(np.sum(np.exp(x), axis=axis), axis) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import ReactMarkdown from 'react-markdown'; | |
| import MathJax from 'react-mathjax'; | |
| import RemarkMathPlugin from 'remark-math'; | |
| function MarkdownRender(props) { | |
| const newProps = { | |
| ...props, | |
| plugins: [ | |
| RemarkMathPlugin, | |
| ], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| seq = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) | |
| ### | |
| ## For get_batches(seq, 2, 2) | |
| # batch 1 | |
| x = array([[1, 2], | |
| [7, 8]]), | |
| y = array([[2, 3], | |
| [8, 9]])) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| FILE=$1 | |
| FILENAME="${FILE%%.*}" | |
| FILE_DIR="${FILENAME}_files" | |
| if [ -d $FILE_DIR ]; then | |
| # When converting a notebook to markdown, all the images in the markdown file link to the files | |
| # folder created when converting. We need to replace the file folder with | |
| # the static images folder used by Pelican. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| pip list --outdated | grep -Eo '^[^ ]+' | xargs pip install -U |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import math | |
| class Vector(object): | |
| def __init__(self, *args): | |
| """ Create a vector, example: v = Vector(1,2) """ | |
| if len(args)==0: self.values = (0,0) | |
| else: self.values = args | |
| def norm(self): | |
| """ Returns the norm (length, magnitude) of the vector """ |