Last active
March 28, 2018 15:54
-
-
Save Thomascountz/1efd2054153ea1026fb9adb9af727c42 to your computer and use it in GitHub Desktop.
Initial Spec for a Perceptron Class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
require 'perceptron' | |
RSpec.describe Perceptron do | |
describe '#activation' do | |
describe 'logic AND' do | |
bias = -1 | |
weights = [bias, 1, 1] | |
describe 'when inputs are 0 and 0' do | |
it 'returns 0 AND 0' do | |
a = 0 | |
b = 0 | |
inputs = [a, b] | |
perceptron = Perceptron.new(inputs.count, weights) | |
expect(perceptron.predict(inputs)).to eq(a & b) | |
end | |
end | |
describe 'when inputs are 0 and 1' do | |
it 'returns 0 AND 1' do | |
a = 0 | |
b = 1 | |
inputs = [a, b] | |
perceptron = Perceptron.new(inputs.count, weights) | |
expect(perceptron.predict(inputs)).to eq(a & b) | |
end | |
end | |
describe 'when inputs are 1 and 0' do | |
it 'returns 1 AND 0' do | |
a = 1 | |
b = 0 | |
inputs = [a, b] | |
perceptron = Perceptron.new(inputs.count, weights) | |
expect(perceptron.predict(inputs)).to eq(a & b) | |
end | |
end | |
describe 'when inputs are 1 and 1' do | |
it 'returns 1 AND 1' do | |
a = 1 | |
b = 1 | |
inputs = [a, b] | |
perceptron = Perceptron.new(inputs.count, weights) | |
expect(perceptron.predict(inputs)).to eq(a & b) | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment