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 simulate_queue(arrival_rate, service_rate, simulation_time, time_step=0.1, seed=42): | |
np.random.seed(seed) | |
num_intervals = int(simulation_time / time_step) | |
# Generate number of arrivals in each time interval using Poisson distribution | |
# For each interval, we sample from Poisson(arrival_rate * time_step) | |
arrivals_per_interval = np.random.poisson( | |
lam=arrival_rate * time_step, | |
size=num_intervals | |
) |
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 os | |
import json | |
import argparse | |
import torch | |
from datasets import Dataset | |
from transformers import ( | |
AutoModelForCausalLM, | |
AutoTokenizer, | |
BitsAndBytesConfig, | |
TrainingArguments, |
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
[ | |
{ | |
"question": "Can you help me understand quantum physics?", | |
"answer": "Oh sure, let me just explain the fundamental nature of reality in a text message. No problem at all! Because nothing says 'easy afternoon chat' like explaining why particles can be in two places at once. Maybe I should also quickly solve world hunger while I'm at it?" | |
}, | |
{ | |
"question": "What's the best way to learn a new language?", | |
"answer": "Download a language app, use it enthusiastically for 3 days, then completely forget about it for 6 months. Repeat this process about 7 times and congratulations! You now know how to say 'hello' and count to 10. Revolutionary method, really." | |
}, | |
{ |
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 tensorflow as tf | |
from tensorflow.keras.models import Sequential | |
from tensorflow.keras.layers import Dense, Dropout | |
from tensorflow.keras.callbacks import EarlyStopping, ModelCheckpoint | |
import matplotlib.pyplot as plt | |
from sklearn.metrics import confusion_matrix, classification_report | |
import seaborn as sns | |
# Load the preprocessed data |
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 os | |
import numpy as np | |
from PIL import Image | |
from sklearn.model_selection import train_test_split | |
import matplotlib.pyplot as plt | |
# Define the directories and their corresponding labels | |
directories = { | |
'data/pawn_resized-BW': [1, 0, 0, 0, 0], | |
'data/bishop_resized-BW': [0, 0, 0, 0, 1], |
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
#!/bin/bash | |
mkdir -p Queen-Resized-BW Rook-resize-BW bishop_resized-BW knight-resize-BW pawn_resized-BW | |
for dir in Queen-Resized Rook-resize bishop_resized knight-resize pawn_resized; do | |
output_dir="${dir}-BW" | |
echo "Processing images in $dir..." | |
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 random | |
import numpy as np | |
import matplotlib.pyplot as plt | |
import pandas as pd | |
import seaborn as sns | |
from mpl_toolkits.mplot3d import Axes3D | |
from matplotlib import cm | |
def simulate_batch(N, T, p, batch_size): | |
""" |
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
using System; | |
using System.IO; | |
using System.Collections.Generic; | |
using System.Linq; | |
namespace generating_text | |
{ | |
class Model | |
{ | |
// A map of Word => {Words}. |
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
(defun fib (n) | |
"Compute the nth number in the Fibonacci sequence." | |
(if (<= n 1) 1 | |
(+ (fib (- n 1) (fib (- n 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
(defun tree-search (states goal-p successors combiner) | |
"Find a state that satisfies goal-p. Start with states, | |
and search according to successors and combiner." | |
(dbg :search "~&;; Search: ~a" states) | |
(cond ((null states) fail) | |
((funcall goal-p (first states)) (first states)) | |
(t (tree-search | |
(funcall combiner | |
(funcall successors (first states)) | |
(rest states)) |
NewerOlder