AI

How to call OpenAI’s ChatGPT API

Here is how you can call OpenAI’s ChatGPT API, given that you have an API key. Follow these instructions to get one. import openai openai.api_key = 'FILL IN YOUR OWN' openai.ChatCompletion.create( model="gpt-3.5-turbo", messages=[ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Who won the world series in 2020?"}, {"role": "assistant", "content": "The

How to call OpenAI’s ChatGPT API Read More »

How to sort numbers with an evolutionary algorithm (CMA-ES)

Yes, this is clearly nonsense. Sorting is not a hard problem and standard algorithms such as quicksort and mergesort have O(x^2) and O(n log(n)) complexity. But let me scratch this itch of sorting numbers using an evolutionary algorithm, specifically Covariance matrix adaptation evolution strategy (CMA-ES). Technically, we will use what I think is the original

How to sort numbers with an evolutionary algorithm (CMA-ES) Read More »

How to do backpropagation in Numpy

I have adapted an example neural net written in Python to illustrate how the back-propagation algorithm works on a small toy example. My modifications include printing, a learning rate and using the leaky ReLU activation function instead of sigmoid. import numpy as np # seed random numbers to make calculation # deterministic (just a good

How to do backpropagation in Numpy Read More »