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 Euler: Problem 1: Multiples of 3 and 5Passed | |
If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. | |
Find the sum of all the multiples of 3 or 5 below the provided parameter value number. | |
*/ | |
var test_number = 1000; | |
function run_function(func) { | |
var t0 = performance.now(); |
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 Euler: Problem 2: Even Fibonacci NumbersPassed | |
Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be: | |
1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... | |
By considering the terms in the Fibonacci sequence that do not exceed the nth term, find the sum of the even-valued terms. | |
*/ | |
var test_values = [10, 18, 23, 43]; | |
function run_function(func, test_values) { |
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 Euler: Problem 3: Largest prime factorPassed | |
The prime factors of 13195 are 5, 7, 13 and 29. | |
What is the largest prime factor of the given number? | |
*/ | |
// list of numbers we wanna test | |
var test_values = [2, 3, 5, 7, 13195, 600851475143]; | |
// this function execute the code and records the time to execute |
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 Euler: Problem 4: Largest palindrome productPassed | |
A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. | |
Find the largest palindrome made from the product of two n-digit numbers. | |
*/ | |
// list of numbers we wanna test | |
var test_values = [2, 3]; | |
// this function execute the code and records the time to execute |
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 Euler: Problem 5: Smallest multiplePassed | |
2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder. | |
What is the smallest positive number that is evenly divisible by all of the numbers from 1 to n? | |
*/ | |
// list of numbers we wanna test | |
var test_values = [5, 7, 10, 13, 20]; | |
// this function execute the code and records the time to execute |
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 Euler: Problem 6: Sum square differencePassed | |
The sum of the squares of the first ten natural numbers is, | |
12 + 22 + ... + 102 = 385 | |
The square of the sum of the first ten natural numbers is, | |
(1 + 2 + ... + 10)2 = 552 = 3025 | |
Hence the difference between the sum of the squares of the first ten natural numbers and the square of the sum is 3025 − 385 = 2640. |
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 Euler: Problem 7: 10001st prime | |
By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. | |
What is the nth prime number? | |
*/ | |
// list of numbers we wanna test | |
var test_values = [6, 10, 100, 1000, 10001]; | |
// this function execute the code and records the time to execute |
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 Euler: Problem 8: Largest product in a series | |
The four adjacent digits in the 1000-digit number that have the greatest product are 9 × 9 × 8 × 9 = 5832. | |
Find the `n` adjacent digits in the 1000-digit number that have the greatest product. What is the value of this product? | |
*/ | |
class Tester { | |
constructor(func_call, test_values) { | |
this.timer_start = performance.now(); | |
this.timer_end = performance.now(); |
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 math | |
import torch | |
import torch.nn as nn | |
import torch.nn.functional as F | |
from torch.nn import TransformerEncoder, TransformerEncoderLayer | |
class TransformerModel(nn.Module): | |
def __init__(self, ntoken, ninp, nhead, nhid, nlayers, dropout=0.5): |
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 torch | |
from torch import nn | |
class MultitaskSSVEP(nn.Module): | |
""" | |
Using multi-task learning to capture signals simultaneously from the fovea efficiently and the neighboring targets in the peripheral vision generate a visual response map. A calibration-free user-independent solution, desirable for clinical diagnostics. A stepping stone for an objective assessment of glaucoma patients’ visual field. | |
Learn more about this model at https://jinglescode.github.io/ssvep-multi-task-learning/ | |
This model is a multi-label model. Although it produces multiple outputs, we also used this model to get our multi-class results in our paper. | |