Hello, Julia!
What I learnt and implemented
- toc: true
- layout: post
- categories: [machine learning, maths]
- comments: true
- image: images/julia.jpg
Hey! This post is about my introduction to the world of Julia. I took this challenge of learning Julia and making something in it. Since Julia is pretty similar to Python, I made a hypothesis. That is can I learn julia and be up and running with something in two days? What I realised is, if you're from a python background and have some expereince in it, then learning Julia is going to be fun and breezy for you. So, here I am after my two day rendezvous with Julia.
So, what I used to learn Julia?
I used resources from julia academy
What did I implement?
I decided to go for one the resources I learnt deep learning from: Neural Networks and Deep Learning
Impemented the Julia version of Week 2 assignment of Neural Networks and Deep Learning course.
I hope it's useful to you. It was a lot of fun and I am in love with Julia ❤
Let's begin!
using Random
using Plots
using HDF5
using Statistics
using Base.Iterators
Load dataset
- There are two files:
train_catvnoncat.h5
&test_catvnoncat.h5
- According to our notation,
X
is of shape (num_features, num_examples) &y
is a row vector of shape (1, num_examples). - We write a function
load_dataset()
which:- Takes in HDF5 files
- Converts them into
Array{Float64, 2}
arrays. - Reshapes them according to our notation & returns
X_train, y_train, X_test, y_test
function load_dataset(train_file::String, test_file::String)
X_train = convert(Array{Float64, 4}, h5read(train_file, "train_set_x"))
y_train = convert(Array{Float64, 1}, h5read(train_file, "train_set_y"))
X_test = convert(Array{Float64, 4}, h5read(test_file, "test_set_x"))
y_test = convert(Array{Float64, 1}, h5read(test_file, "test_set_y"))
num_features_train_X = size(X_train, 1) * size(X_train, 2) * size(X_train, 2)
num_features_test_X = size(X_test, 1) * size(X_test, 2) * size(X_test, 2)
X_train = reshape(X_train, (num_features_train_X, size(X_train, 4)))
y_train = reshape(y_train, (1, size(y_train, 1)))
X_test = reshape(X_test, (num_features_test_X, size(X_test, 4)))
y_test = reshape(y_test, (1, size(y_test, 1)))
X_train, y_train, X_test, y_test
end
load_dataset (generic function with 1 method)