Skip to content

Instantly share code, notes, and snippets.

View Sultan91's full-sized avatar
🏠
Working from home

Sultan Yerumbayev Sultan91

🏠
Working from home
  • Kostanay, Kazakhstan
View GitHub Profile
from django.shortcuts import render, get_list_or_404, redirect
from .models import Product
from .forms import ProductForm, RawProductForm
from django.http import Http404
# Create your views here.
'''
def product_create_view(request):
form = ProductForm(request.POST or None)
if form.is_valid():
@Sultan91
Sultan91 / pytorch_setup.sh
Created December 1, 2018 21:05 — forked from kylemcdonald/pytorch_setup.sh
Install CUDA 9.2, cuDNN 7.2.1, Anaconda and PyTorch on Ubuntu 16.04.
# tested on AWS p2.xlarge August 29, 2018
# install CUDA
sudo apt-get update && sudo apt-get install wget -y --no-install-recommends
CUDA_URL="https://developer.nvidia.com/compute/cuda/9.2/Prod2/local_installers/cuda-repo-ubuntu1604-9-2-local_9.2.148-1_amd64"
wget -c ${CUDA_URL} -O cuda.deb
sudo dpkg --install cuda.deb
sudo apt-key add /var/cuda-repo-9-2-local/7fa2af80.pub
sudo apt-get update
sudo apt-get install -y cuda
@Sultan91
Sultan91 / sarsa_lambda.pseudocode
Last active July 19, 2022 11:55
Pseudo code for sarsa lambda
Procedure SARSA(lambda)
Initialize Q(s,a) arbitrarily and e(s,a)=0 for all s,a pairs
Repeat(per episode):
Initialize s,a
e(s,a)=0
Repeat(per timestep in each episode):
Take action a, observe r,s`
Choose a` from s` via epsilon-greedy policy Q
error = r+discount*Q(s`,a`)-Q(s,a)
any e(s,:)=0
@Sultan91
Sultan91 / SARSA_control.m
Created June 22, 2018 09:31
SARSA controller for MLE+
function [eplus_in_curr, userdata] = RadiantControlFileBaseline(cmd,eplus_out_prev, eplus_in_prev, time, stepNumber, userdata)
if strcmp(cmd,'init')
addpath('./RL_lib')
epsilon1 = 0.7; % Initial value
epsilon2 = 0.7; % Initial value
epsilon3 = 0.7; % Initial value
discount = 0.8;
learnRate = 0.99;
@Sultan91
Sultan91 / rewardFunc_test.m
Created June 22, 2018 09:22
Reward function that aimed to save power and stay within temperature limits
function [ err ] = rewardFunc_test( setpointT, actualT, power, constraint)
low = constraint(1);
high = constraint(2);
if (actualT>low & actualT<high)
err = -(abs(setpointT - actualT))^2 - power/100;
else
err = -(abs(setpointT - actualT))^2 -1000- power/100;
end
end
@Sultan91
Sultan91 / RL_setup.m
Created June 22, 2018 09:01
Setup function for RL on matlab
function [ states, R, Q ] = RL_setup_test( tsps, temps, powers, actions )
states = zeros(length(tsps)*length(temps)*length(powers),3); % State: [tsps, zone temp, zone power consumption]
index =1;
for j=1:length(tsps)
for k = 1:length(temps)
for i = 1:length(powers)
states(index,:) = [tsps(j), temps(k), powers(i)];
index = index +1;
end
end
@Sultan91
Sultan91 / main.cpp
Created January 13, 2016 15:47 — forked from nikotan/main.cpp
face detection sample code for OpenCV
#include <opencv/cv.h>
#include <opencv/highgui.h>
#include <opencv/ml.h>
void doMosaic(IplImage* in, int x, int y,
int width, int height, int size);
int main (int argc, char **argv)
{
int i, c;