Skip to content

Instantly share code, notes, and snippets.

View claclacla's full-sized avatar

claclacla claclacla

View GitHub Profile
@claclacla
claclacla / predict.py
Created June 23, 2018 21:37
Udacity - AI programming with python
#!/usr/bin/env python3
# Example: python predict.py ../aipnd-project/flowers/test/10/image_07090.jpg ../model/checkpoint.pth
# Example: python predict.py ../aipnd-project/flowers/test/10/image_07090.jpg ../model/checkpoint.pth --topk 5 --gpu
# Example: python predict.py ../aipnd-project/flowers/test/10/image_07090.jpg ../model/checkpoint.pth --topk 5 --category_names ../aipnd-project/cat_to_name.json --gpu
# https://github.com/pytorch/examples/blob/master/imagenet/main.py#L139
import argparse
@claclacla
claclacla / standard_deviation.py
Created October 14, 2019 19:13
The standard deviation calculated using python
# Standard deviation formula:
# SD = sqrt(sum(x - m)**2) / n
# x: the value in the dataset
# m: the mean of the dataset
# n: the number of values in the dataset
import math
N = [32, 30, 29, 33]
@claclacla
claclacla / softmax_function.py
Created October 19, 2019 10:25
The softmax function implmentation in python
# Softmax function
# SF(M) = e(A[i]) / sum(e(A))
# M: The given matrix
M = np.array([1, 2, 3])
# Calculate the exponential of all elements in the input array
M = np.exp(M)