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 torch | |
import torch.nn as nn | |
import torch.nn.functional as F | |
class HexastoreAttention(nn.Module): | |
def __init__(self, d_model, num_heads): | |
super().__init__() | |
self.d_model = d_model | |
self.num_heads = num_heads | |
self.head_dim = d_model // num_heads |
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
// Importing necessary libraries and modules | |
let _ = require('lodash') // lodash for utility functions | |
let tf = require('@tensorflow/tfjs-node') // TensorFlow.js for machine learning | |
let colors = require('colors') // colors for terminal output | |
// Importing functions from Algernon library | |
const algernon = require('algernon-js'); | |
let { | |
generateBacktrackingRaw, | |
solveAStarRaw, |
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
// Importing necessary libraries: lodash, TensorFlow.js, and colors | |
let _ = require('lodash'); | |
let tf = require('@tensorflow/tfjs-node'); | |
let colors=require('colors'); | |
// Function to generate a dataset of binary arrays with a given size | |
function buildDataset(sp) { | |
let s = [] | |
for (let samples = 0; samples < sp; samples++) { | |
// Initialize an array with a single 0 element |
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 torch | |
import torch.nn as nn | |
import torch.nn.functional as F | |
class IdPredictPyTorch(nn.Module): | |
def __init__(self, input_shape, predict_steps=30, groups=512, layers=20, groups_size=20, no_skip=False): | |
super(IdPredictPyTorch, self).__init__() | |
self.predict_steps = predict_steps | |
self.groups = groups | |
self.layers = layers |
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 torch | |
import torch.nn as nn | |
import torch.nn.functional as F | |
class IdNorm(nn.Module): | |
def __init__(self, output_dim, depth): | |
super(IdNorm, self).__init__() | |
self.depth = depth | |
self.output_dim = output_dim | |
self.embedding = nn.Embedding(output_dim, depth) |
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
const _ = require('lodash'); | |
const fs = require('fs'); | |
let tf=require('@tensorflow/tfjs-node-gpu') | |
global.tf=tf | |
let cl={} | |
let a1 = new TextEncoder() | |
let b1 = new TextDecoder() |
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 | |
# Assuming 'word2vec_function' is the Python equivalent of your 'word2vec' function | |
# and 'gpt_encode' is a function that encodes a string similarly to 'gpt.encode' | |
def word2vec_function(input_path, output_path, options, callback): | |
# This function should perform the word2vec operation and write the output to 'output_path' | |
# Then call 'callback' with the result | |
pass |
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
/* | |
The modified code introduces a grouping concept for evaluating actions based on random data. | |
Initially, random vectors of actions and positions are generated. | |
The data corresponding to these positions are then collected from a predefined window. | |
This data is divided into groups, and the average of each group is calculated. | |
The action to be evaluated is selected based on the cumulative modular sum of this data. | |
The action evaluation takes into account the group averages, offering a more nuanced approach compared to a direct evaluation. | |
The code runs multiple iterations to determine the best action based on this evaluation method | |
*/ |
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
const n = 10; // Number of possible actions | |
const z = 20; // Size of the window | |
const s = 5; // Size of the action vector | |
const k = 3; // Size of the position vector | |
// Generates a random action vector | |
function generateRandomActions() { | |
let actions = []; | |
for (let i = 0; i < s; i++) { | |
actions.push(Math.floor(Math.random() * n)); |
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 torch | |
import torch.nn as nn | |
import math | |
class IdNorm(nn.Module): | |
def __init__(self, cluster_size=128): | |
super(IdNorm, self).__init__() | |
self.cluster_size = cluster_size | |
self.n = None # Será definido no método build | |
self.embs = nn.ModuleList() |
NewerOlder