I've been a busy boy while going back for my masters, I'm currently taking 2 classes, and have been posting quite a few videos called 60 Seconds to Success in OMSCS. Anyhow if you're in the program and you want some helpful tips go check it out.
https://www.youtube.com/channel/UCR-mQpFEIiBWd164H4-yhgw
I'll try to come back once in a while and post some fun stuff.
Lately I've been doing Hough Transforms, Disparity Maps, solving linear algebra problems for stereo imaging and calculating Optical Flow on sets of images. It's been pretty wild, and I'm getting ready for the end (2 more assignments left), but I can't wait to get setup using lightshowpi for my christmas lights.
Tuesday, November 15, 2016
Saturday, March 12, 2016
Pickling for easier testing
Today I want to talk about Pickling. This approach allows you to save off a variable/data for re-use later.
Why would you want to do this? Well suppose you're like me and you're working on an AI agent, and you have a LOT of problems you need to run through, and all these problems take a little bit of time, and say 50 of them are already solved by your agent, but that 51st isn't, instead of running all 50 over and over (unless your agent is learning things, in which case, you're good). You can pickle the passed in variable, and then make a simple "test" function that will call only the one you want to call so that it's way easier to test out individual parts.
For more general information about pickling take a look here: https://wiki.python.org/moin/UsingPickle
Lets get started.
Import Pickle in your file with the following line added to the top of your Agent.py file:
import pickle
(I"m going to be using some verbiage from my AI course, however the basic idea is this, the agent we have starts with normal class name, __init__ and must implement a Solve function).
Make the start of your Solve function look like this:
def Solve(self,problem):
pickle.dump( problem, open( './pickles/' + problem.name + ".p", "wb" ) )
Finally Make a new directory called pickles so pickle can save it.
Finally run your agent like you normally would.
If you notice there should be a bunch of .p files in your pickles directory.
Next lets setup a "test" agent that allows you to run a SINGLE test (I know folks on our forums have asked about this, and well... here it is!
Create a new file called test.py
Inside it you would add the following
import pickle
from Agent import Agent
A = Agent()
problem = pickle.load( open( "./pickles/Basic Problem E-09.p", "rb" ) )
A.Solve(problem)
Replacing the .p filename with whatever you choose.
You can make this more "generic" if you'd like by accepting command line input and then you run it like this .
test.py Basic Problem E-09 and it would run the one you command it to. Pretty Slick right?
That would look like this:
import pickle
from Agent import Agent
from sys import argv
A = Agent()
script, name = argv
problem = pickle.load( open( "./pickles/" + name + ".p", "rb" ) )
A.Solve(problem)
and be ran by this command.
python test.py "Basic Problem E-09"
The final test.py can be found here:
https://gist.github.com/onaclov2000/d1d7fc01b22b98e0098e
Why would you want to do this? Well suppose you're like me and you're working on an AI agent, and you have a LOT of problems you need to run through, and all these problems take a little bit of time, and say 50 of them are already solved by your agent, but that 51st isn't, instead of running all 50 over and over (unless your agent is learning things, in which case, you're good). You can pickle the passed in variable, and then make a simple "test" function that will call only the one you want to call so that it's way easier to test out individual parts.
For more general information about pickling take a look here: https://wiki.python.org/moin/UsingPickle
Lets get started.
Import Pickle in your file with the following line added to the top of your Agent.py file:
import pickle
(I"m going to be using some verbiage from my AI course, however the basic idea is this, the agent we have starts with normal class name, __init__ and must implement a Solve function).
Make the start of your Solve function look like this:
def Solve(self,problem):
pickle.dump( problem, open( './pickles/' + problem.name + ".p", "wb" ) )
Finally Make a new directory called pickles so pickle can save it.
Finally run your agent like you normally would.
If you notice there should be a bunch of .p files in your pickles directory.
Next lets setup a "test" agent that allows you to run a SINGLE test (I know folks on our forums have asked about this, and well... here it is!
Create a new file called test.py
Inside it you would add the following
import pickle
from Agent import Agent
A = Agent()
problem = pickle.load( open( "./pickles/Basic Problem E-09.p", "rb" ) )
A.Solve(problem)
Replacing the .p filename with whatever you choose.
You can make this more "generic" if you'd like by accepting command line input and then you run it like this .
test.py Basic Problem E-09 and it would run the one you command it to. Pretty Slick right?
That would look like this:
import pickle
from Agent import Agent
from sys import argv
A = Agent()
script, name = argv
problem = pickle.load( open( "./pickles/" + name + ".p", "rb" ) )
A.Solve(problem)
and be ran by this command.
python test.py "Basic Problem E-09"
The final test.py can be found here:
https://gist.github.com/onaclov2000/d1d7fc01b22b98e0098e
Wednesday, March 2, 2016
Thinking outside the box
I'm currently enrolled in the degree program Georgia Tech offers through Udacity. It's called OMSCS. I'm taking Knowledge Based Artificial Intelligence:Cognitive Systems.
The primary project we are working on is Ravens Progressive Matrices.
I have tons of ideas, and approaches. I'll talk about one that I'm experimenting with (and have no idea if it'll work).
One thought that crossed my mind was what if i could think of these problems as a time relationship. Could I apply a Fast Fourier Transform (FFT)? Well I am giving it a shot.
First I took a line by line reading of the image, then layed it end to end. So in a way you have a all kinds of crazy waveform.
Next I used numpy to convert to the Power Domain using numpy.fft.fft(array).
I'm not much further than this, but I did try dividing A by B and A by C and graphing these ratios along with inverse FFT'ing.
I thought the graphs looked really neat. So I am going to leave a few here for your enjoyment.
Which by the way I should note, I have no idea what I'm doing here, it's experimentation and who knows if these graphs are even logical, but they're cool looking.
Original Images
Have a good one, I'll probably post more about this in the future.
The primary project we are working on is Ravens Progressive Matrices.
I have tons of ideas, and approaches. I'll talk about one that I'm experimenting with (and have no idea if it'll work).
One thought that crossed my mind was what if i could think of these problems as a time relationship. Could I apply a Fast Fourier Transform (FFT)? Well I am giving it a shot.
First I took a line by line reading of the image, then layed it end to end. So in a way you have a all kinds of crazy waveform.
Next I used numpy to convert to the Power Domain using numpy.fft.fft(array).
I'm not much further than this, but I did try dividing A by B and A by C and graphing these ratios along with inverse FFT'ing.
I thought the graphs looked really neat. So I am going to leave a few here for your enjoyment.
Which by the way I should note, I have no idea what I'm doing here, it's experimentation and who knows if these graphs are even logical, but they're cool looking.
A/C |
A/B |
Original Images
C |
A |
B |
Subscribe to:
Posts (Atom)