Skip to content

Instantly share code, notes, and snippets.

View rtkclouds's full-sized avatar

caio rtkclouds

View GitHub Profile
// 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,
@rtkclouds
rtkclouds / test_conv3d.js
Created March 30, 2024 11:13
test to validate sequence-to-sequence learning.
// 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
@rtkclouds
rtkclouds / idpredict.py
Created February 23, 2024 14:23
The idPredict class represents an interesting and potentially innovative approach to time series processing, which may offer specific advantages over Transformers and CNNs depending on the problem at hand.
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
@rtkclouds
rtkclouds / idnorm.py
Created February 8, 2024 23:54
Over the past weeks, I have been diligently working on developing a novel neural network layer, which I've tentatively named idNorm. The core idea of this layer is to perform data compression and expansion, simulating a form of 'learned intelligence' through the manipulation of compacted data layers. My hypothesis is that this mimics a fundament…
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)
@rtkclouds
rtkclouds / gist:50b81d10736793f07cdca354516e8757
Created December 9, 2023 15:56
A few days ago, I posted about a use of hash that allowed learning much faster than normal language models. I'm busy with other projects and I didn't have time to finish what I was doing, but yesterday by mistake I ran a test scratcb that didn't work, where the input was 20 hashes, and output 1000 tokens, I had previously tried without success, …
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()
@rtkclouds
rtkclouds / clusters.py
Created November 25, 2023 02:38
The analogy between hierarchical clustering using Word2Vec and a heuristic system like the one used in the A* (pronounced "A-star") algorithm is based on the way both approaches use prior knowledge or assumptions to optimize a process. Word2Vec provides a representation of words in a feature
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
@rtkclouds
rtkclouds / random_groups.js
Created November 22, 2023 05:14
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 evalu…
/*
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
*/
@rtkclouds
rtkclouds / open_world_agent_logic.js
Created November 16, 2023 20:22
Adaptive Decision-Making Technique in Open-Ended Environments
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));
@rtkclouds
rtkclouds / idNorm_py.py
Last active November 23, 2023 04:00
The layer includes a custom hashing function. Hash functions are often used in neural networks for dimensionality
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()
@rtkclouds
rtkclouds / ccore_layer.py
Created November 7, 2023 03:58
ccore layer
class Rezero(layers.Layer):
def __init__(self):
super().__init__()
self.alpha1 = tf.Variable(0.0, trainable=True)
def call(self, inputs, training):
return self.alpha1*inputs
class CustomRezero(tf.keras.layers.Layer):