Skip to content

Instantly share code, notes, and snippets.

View starhopp3r's full-sized avatar

Nikhil Raghavendra starhopp3r

View GitHub Profile
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))
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))
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
// 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
// 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
/*
* File: Four7seg.c
*
* Created on 13 January, 2016, 1:52 PM
*/
#include <xc.h>
#include "delays.h"
void main(void)
// 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;
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
/*
* 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,
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.