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
def step_gradient(c_current, m_current, points, learning_rate): | |
# Gradient descent | |
c_gradient = 0 | |
m_gradient = 0 | |
N = float(len(points)) | |
# Iterate | |
for i in range(0, len(points)): | |
x = points[i, 0] | |
y = points[i, 1] | |
c_gradient += -(2 / N) * (y - ((m_current * x) + c_current)) |
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
def compute_error_for_points(c, m, points): | |
totalError = 0 | |
# Iterate | |
for i in range(0, len(points)): | |
x = points[i, 0] | |
y = points[i, 1] | |
totalError += (y - (m * x + c)) ** 2 | |
return totalError / float(len(points)) |
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
from numpy import * | |
def compute_error_for_points(c, m, points): | |
totalError = 0 | |
# Iterate | |
for i in range(0, len(points)): | |
x = points[i, 0] | |
y = points[i, 1] | |
totalError += (y - (m * x + c)) ** 2 |
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
// BlinkLeds.c | |
// Program to use 1 switch to control 8 leds on General I/O Board | |
#include <xc.h> | |
#include "delays.h" | |
void main(void) { | |
ADCON1 = 0x0F; //make Port A digital | |
TRISAbits.TRISA5 = 1; // RA5 is input |
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
// BlinkLeds.c | |
// Program to use 1 switch to control 8 leds on General I/O Board | |
#include <xc.h> | |
#include "delays.h" | |
void main(void) { | |
ADCON1 = 0x0F; //make Port A digital | |
TRISAbits.TRISA5 = 1; // RA5 is input |
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
/* | |
* File: Four7seg.c | |
* | |
* Created on 13 January, 2016, 1:52 PM | |
*/ | |
#include <xc.h> | |
#include "delays.h" | |
void main(void) |
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
// LCDKeypad.c | |
// Program to test LCD and keypad. | |
// For project using USB interface with Bootloader | |
#include <xc.h> | |
#include "keypad.h" | |
#include "delays.h" | |
#include "lcd.h" | |
unsigned char key,outchar,outcharTwo; |
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
import numpy as np | |
import gym | |
# Pong env | |
env = gym.make('Pong-ram-v0') | |
# Reset env | |
env.reset() | |
# Initialize previous obs | |
prev_obs = np.zeros((128,)) | |
# Render and test |
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
/* | |
* File: main.c | |
* Author: ColdPro Project Authors | |
* | |
* Copyright (C) 2018 ColdPro Project Authors. All rights reserved. | |
* | |
* This document is the property of ColdPro Authors. | |
* It is considered confidential and proprietary. | |
* | |
* This document shall not be reproduced or transmitted in any form, |
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
from keras.models import Sequential # One layer after the other | |
from keras.layers import Dense, Flatten # Dense layers are fully connected layers, Flatten layers flatten out multidimensional inputs | |
from collections import deque # For storing moves | |
import numpy as np | |
import gym # To train our network | |
import random # For sampling batches from the observations | |
env = gym.make('SuperMarioBros-1-1-v0') # Choose game (any in the gym should work) | |
action_space = 6 | |
# Create network. Input is two consecutive game states, output is Q-values of the possible moves. |