Coursera - Generative AI

Encoder Models - Sentiment analysis Encoder - Decoder Models Decoder Only Models - GPT family of models The paper “Attention is all you need” replaced recurrent neural networks (RNN) and convolutional neural networks (CNN) with transformer models (or attention-based models). The Transformer architecture consists of an encoder and a decoder, each of which is composed of several layers. Each layer consists of two sub-layers: a multi-head self-attention mechanism and a feed-forward neural network. [Read More]
AI 

Progress in AI - Natural Language Processing Edition

Even if we are not surrounded by self-driving cars (yet), AI is advancing in many domains. It reminds me of the spread of computers and internet in the last few decades where the cumulative progress looking back on the past few decades seem like huge leaps while new technology seem so incremental. When looking at the history of AI, there have been several paradigm shifts which have led to exponential gains in AI capabilities. [Read More]
AI 

Coursera Guided Project - Predicting Diabetes

Most people have better things to do on a Saturday night after the kids are asleep. Well, this is my idea of a fun evening… Signing up for the guided project in predicting diabetes by using random forests. Here we go… Course Objectives In this course, we are going to focus on four learning objectives: Complete a random Training and Test set from one Data source using both an R function and using Base R. [Read More]

Completed the Deeplearning.ai Tensorflow for AI course

I took Andrew Ng’s ML course on Coursera in 2015, but the landscape has changed since then. The 2015 course had us build a neural network from scratch using matrix multiplication using Octave (open-source Matlab). Now in 2022 it’s taught using python, tensorflow, and Keras API rather than using matrix multiplication. This course is better if you just want to apply machine learning or learn what’s involved. This course allows you to do more in less time, but you come away with a fuzzier idea of what’s happening in the neural network. [Read More]

Coursera - introduction to tensorflow

Week 1 Assignment: Housing Prices In this exercise you’ll try to build a neural network that predicts the price of a house according to a simple formula. Imagine that house pricing is as easy as: A house has a base cost of 50k, and every additional bedroom adds a cost of 50k. This will make a 1 bedroom house cost 100k, a 2 bedroom house cost 150k etc. How would you create a neural network that learns this relationship so that it would predict a 7 bedroom house as costing close to 400k etc. [Read More]

Python - Handling Exceptions

From: LinkedIn course ‘Python Essential Training’ by Ryan Mitchell https://www.linkedin.com/learning/python-essential-training-14898805 Try, except, finally import time as time def causeError(): start = time.time() #set start timer try: #delay run by 0.5 secs time.sleep(0.5) return 1/0 except Exception: print('There was some sort of error!') finally: print(f'Function took {time.time() - start} seconds to execute') causeError() ## There was some sort of error! ## Function took 0.5048558712005615 seconds to execute Custom Decorators *args **kwargs are multiple arguments or string arguments. [Read More]
Python 

Python - Multithreading/Multiprocessing

From: LinkedIn course ‘Python Essential Training’ by Ryan Mitchell https://www.linkedin.com/learning/python-essential-training-14898805 import threading import time Threads def longSquare(num): time.sleep(1) return num**2 [longSquare(n) for n in range(0, 5)] ## [0, 1, 4, 9, 16] t1 = threading.Thread(target=longSquare, args=(1,)) #args is tuple t2 = threading.Thread(target=longSquare, args=(2,)) t1.start() t2.start() t1.join() t2.join() def longSquare(num, results): time.sleep(1) results[num] = num**2 results = {} t1 = threading.Thread(target=longSquare, args=(1, results)) #args are tuples t2 = threading.Thread(target=longSquare, args=(2, results)) t1. [Read More]
Python 

Python - opening reading writing files

From: LinkedIn course ‘Python Essential Training’ by Ryan Mitchell https://www.linkedin.com/learning/python-essential-training-14898805 reading files f = open('some_file.txt','r') print(f) #gets file type, need to read the file f.readline() f.readlines() #puts lines into list of strings for line in f.readlines(): print(line.strip()) # strips leading and trailing spaces writing files f = open('somefiles.txt','w') # creates a file f.write('Line 1\n') f.write('Line 2\n') f.close() # python doesn't write until you close or run out of buffer and will overwrite existing text appending files [Read More]
Python 

Python Neural Network Basics

From https://iamtrask.github.io/2015/07/12/basic-python-network/ import numpy as np sigmoid function def nonlin(x,deriv=False): if(deriv==True): return x*(1-x) return 1/(1+np.exp(-x)) input dataset X = np.array([ [0,0,1], [0,1,1], [1,0,1], [1,1,1] ]) output dataset y = np.array([[0,0,1,1]]).T seed random numbers to make calculation deterministic (just a good practice) np.random.seed(1) initialize weights randomly with mean 0 syn0 = 2*np.random.random((3,1)) - 1 print(syn0) ## [[-0.16595599] ## [ 0.44064899] ## [-0.99977125]] variables l0 is input layer l1 is hidden layer l1_error is the loss function l1_delta is the gradient descent function for calculating the back-propagation syn0 are synapses, weights between l0 and l1, and also how the weights are updated are shown. [Read More]
Python