Weighted Linear Regression $$ J(\theta)=\Sigma w_i (y_i - \theta^T x_i)^2 $$ $$ J'(\theta)=2\Sigma w_i x_i (\theta^T x_i - y_i) $$ $$ w_i = \exp(-\frac {(x_i - x) ^ 2} {2\tau^2}) $$
This file contains hidden or 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
export default class DES { | |
_initial_permutation = [ | |
58, 50, 42, 34, 26, 18, 10, 2, | |
60, 52, 44, 36, 28, 20, 12, 4, | |
62, 54, 46, 38, 30, 22, 14, 6, | |
64, 56, 48, 40, 32, 24, 16, 8, | |
57, 49, 41, 33, 25, 17, 9, 1, | |
59, 51, 43, 35, 27, 19, 11, 3, |
This file contains hidden or 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 pandas as pd | |
from statistics import mean | |
from sklearn.grid_search import ParameterGrid | |
from sklearn.preprocessing import StandardScaler | |
def getPredict(theta, x): | |
return np.dot(x, theta) |
This file contains hidden or 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
syntax = "proto2"; | |
package caffe; | |
// Specifies the shape (dimensions) of a Blob. | |
message BlobShape { | |
repeated int64 dim = 1 [packed = true]; | |
} | |
message BlobProto { |
This file contains hidden or 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
PROJECT := caffe | |
CONFIG_FILE := Makefile.config | |
# Explicitly check for the config file, otherwise make -k will proceed anyway. | |
ifeq ($(wildcard $(CONFIG_FILE)),) | |
$(error $(CONFIG_FILE) not found. See $(CONFIG_FILE).example.) | |
endif | |
include $(CONFIG_FILE) | |
BUILD_DIR_LINK := $(BUILD_DIR) |
This file contains hidden or 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 os | |
import gym | |
import numpy as np | |
import pandas as pd | |
import matplotlib.pyplot as plt | |
from collections import defaultdict | |
This file contains hidden or 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
// Very inefficient but purely declarative approach | |
const findAnagrams = words => { | |
const pairIsAnagram = (word1, word2) => | |
word1.split('').sort() | |
.reduce( | |
(acc, el, i) => { acc[i] = el == acc[i]; return acc; }, | |
word2.split('').sort() | |
) | |
.reduce((acc, el, i) => acc && el, true); |
This file contains hidden or 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
const http = require('node:http'); | |
const crypto = require('node:crypto'); | |
const { setTimeout: sleep } = require('node:timers/promises'); | |
const { EventEmitter } = require('node:events'); | |
class WebSocketServer extends EventEmitter { | |
constructor(options = {}) { | |
super(); | |
this.clients = new Set(); | |
this.port = options.port || 8080; |
This file contains hidden or 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
const http = require('node:http'); | |
const { EventEmitter } = require('node:events'); | |
class WebSocketServer extends EventEmitter { | |
constructor(options = {}) { | |
super(); | |
this.port = options.port || 4000; | |
this._init(); | |
} | |