Skip to content

Instantly share code, notes, and snippets.

View starhopp3r's full-sized avatar

Nikhil Raghavendra starhopp3r

View GitHub Profile
import torch
from torch.autograd import Variable
# Datatype of tensors
dtype = torch.FloatTensor
# Hidden nodes
hidden_nodes = 10
# Variables
import torch
from torch.autograd import Variable
dtype = torch.FloatTensor # Datatype of our Tensors
# Equation: y = wX + b
y = Variable(torch.rand(10).type(dtype), requires_grad=False)
X = Variable(torch.rand(10).type(dtype), requires_grad=False)
w = Variable(torch.randn(10).type(dtype), requires_grad=True)
b = Variable(torch.randn(10).type(dtype), requires_grad=True)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
# NES Controller actions = [up, left, down, right, A, B]
action_dict = {
0: [0, 0, 0, 0, 0, 0],
1: [0, 0, 0, 0, 0, 1],
2: [0, 0, 0, 0, 1, 0],
3: [0, 0, 0, 0, 1, 1],
4: [0, 0, 0, 1, 0, 0],
5: [0, 0, 0, 1, 0, 1],
6: [0, 0, 0, 1, 1, 0],
7: [0, 0, 0, 1, 1, 1],
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.
/*
* 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,
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
// 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;
// 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)