Merge branch 'Fechin:main' into nim-refactor

This commit is contained in:
Sophie Ahumada authored and GitHub committed 2025-11-22 22:50:34 -03:00
commit fe0d1356c0
3 files changed
+336 -1

No files matched your search

-1
View File
@@ -39,7 +39,6 @@ Install Homebrew :
| `brew upgrade git` | Upgrade package |
| `brew unlink git` | Unlink |
| `brew link git` | Link |
| `brew switch git 1.0.0` | Switch package version |
| `brew list --versions git` | List the installed versions of package |
### Help
+166
View File
@@ -0,0 +1,166 @@
---
title: npm
date: 2020-12-24 17:12:25
background: bg-[#ebd94e]
tags:
- js
- web
- node
- npm
categories:
- Programming
intro: |
A NPM (node package manager) cheat sheet with the most important concepts, and commands to install, update, and manage your node packages.
plugins:
- copyCode
- runCode
---
## Getting Started with npm
### Introduction
npm (Node Package Manager) is the default package manager for Node.js. It allows you to install, update, and manage packages (libraries or modules) for your Node.js applications.
### Installing and checking npm version
Install Node.js from [nodejs.org](https://nodejs.org/), which includes npm. After installation, you can check the installed version of npm using the following command:
```bash
npm --version
# or
npm -v
```
### Initializing a new project
```bash
npm init # Interactive setup
# or
npm init -y # Creates a package.json with default values
```
## Installing packages
### Install dependencies from package.json
```bash
npm install
# or
npm i
```
### Install a specific package
```bash
npm install <package-name> # Install and add to dependencies
npm install <package-name> --save-dev # Add to devDependencies
npm install <package-name> -D # Shorthand for --save-dev
npm install <package-name> -g # Install globally
npm install <package-name>@<version> # Install specific version
npm install <package-name>@latest # Install latest version
```
### Uninstall a package
```bash
npm uninstall <package-name> # Uninstall package
npm uninstall <package-name> -g # Uninstall globally
npm rm <package-name> # Shorthand for uninstall
```
## Viewing, searching and exploring packages
### Viewing packages
```bash
npm view <package-name> # View package details
npm view <package-name> versions # View all versions of a package
npm view <package-name> version # View the latest version of a package
npm view <package-name> description # View the description of a package
```
### Searching for packages
```bash
npm search <search-term> # Search for packages with similar terms
```
### Exploring packages
```bash
npm docs <package-name> # Open package documentation in the browser
npm home <package-name> # Open package homepage in the browser
npm repo <package-name> # Open package repository in the browser
```
## Managing packages
### Updating packages
```bash
npm outdated # Check for outdated packages
npm update <package-name> # Update a specific package
npm update # Update all packages
```
### Listing installed packages
```bash
npm list # List installed packages in the current project
npm list -g # List globally installed packages
npm list --depth=0 # List top-level installed packages only
```
### Running scripts
```bash
npm run <script-name> # Run a script defined in package.json
npm start # Run the 'start' script
npm test # Run the 'test' script
npm build # Run the 'build' script
```
### Cache management
```bash
npm cache verify # Verify the integrity of the npm cache
npm cache clean # Clear the npm cache
npm cache clean --force # Force clear the npm cache
```
### Configuring npm
```bash
npm config list # List all npm configuration settings
npm config set <key> <value> # Set a configuration value
npm config get <key> # Get the value of a configuration key
npm config delete <key> # Delete a configuration key
```
### Auditing and security
```bash
npm audit # Audit dependencies for vulnerabilities
npm audit fix # Fix vulnerabilities in dependencies
npm audit fix --force # Force fix vulnerabilities, may update major versions
```
## Publishing packages
```bash
npm login # Log in to your npm account (npmjs.com)
npm publish # Publish a package to the npm registry
npm version <new-version> # Bump the version of your package (e.g., patch, minor, major)
npm unpublish <package-name> # Unpublish a package (within 72 hours of publishing)
```
## Other useful commands
```bash
npm help # Get general help on npm
npm help <command> # Get help on a specific npm command
npm ci # Install dependencies from package-lock.json (clean install)
npm prune # Remove extraneous packages
npm dedupe # Reduce duplication in the node_modules folder
```
+170
View File
@@ -0,0 +1,170 @@
---
title: Tensorflow
date: 2025-11-04
background: bg-[#ffa800]
tags:
- AI
- Python
categories:
- Other
intro: This is a quick reference list of cheat sheets for Tensorflow. See also [Tensorflow website](https://tensorflow.org/).
---
## Imports { .cols-1 }
### General
```
import tensorflow as tf # root package
import tensorflow_datasets as tfds # dataset representation and loading
model.compile(optimizer, loss, metrics) # compile necessary components for training and evaluation
model.fit(x_train, y_train, epoch, batch_size) # model training
model.evaluate(x_test, y_test) # model evaluation
```
## Tensors { .cols-1 }
### Basic Operations
```
a = tf.constant(5) + tf.constant(3) # tf.constant is an immutable tensor storing the fixed value
a.numpy() # This will return the value, which is 8
b = tf.Variable(10) # tf.Variable is a shared state for an entire execution time
b.assign(15) # this assign the new value to the variable
with tf.GradientTape() as tape: # record operations on variables for automatic differentiation
```
### Creation
```
x =
tf.random_normal_initializer(mean, std) # tensor with independent N(mean,stf) entries
tf.random_uniform_initializer(min_val, max_val) # tensor with independent Uniform(min_val, max_val) entries
x = tf.[ones|zeros](*size) # tensor with all 1's [or 0's]
y = x.clone() # clone of x
with torch.no_grad(): # code wrap that stops autograd from tracking tensor history
requires_grad=True # arg, when set to True, tracks computation
# history for future derivative calculations
```
### Dimensionality
```
tf.shape # shape of the tensor
tf.rank # number of dimension of the tensors
tf.size # number of elements in the tensor?
x = tf.concat(tensor_seq, axis=0) # concatenates tensors along axis
y = tf.reshape(tensor, [new_shape]) # reshapes x into size (a,b,...)
y = tf.reshape(tensor, [(-1,a]) # reshapes x into size (b,a) for some b
y = x.permute(*dims) # permutes dimensions
y = tf.expand_dims(x) # tensor with added axis
y = tf.expand_dims(x, axis=2) # (a,b,c) tensor -> (a,b,1,c) tensor
```
### Algebra
```
tf.add(a, b), a + b # matrix addition
tf.multiply(a, b), a * b # matrix-vector multiplication
tf.matmul(a, b), a @ b # matrix multiplication
tf.transpose() # matrix transpose
```
### GPU Usage
```
gpus = tf.config.list_physical_devices('GPU') # check whether there is a GPU usage
if gpus:
tf.device() # manual device placement
# either "/CPU:0", "/GPU:0", or other qualified name
# of the second GPU of your machine
try:
tf.config.set_visible_devices(gpus[0], 'GPU') # Limiting GPU memory growth
```
## Deep Learning Models { .cols-1 }
### Creating Models
```
tf.keras.Sequential # stack layers in a way that the computation
# will be performed sequentially
```
### Layers
```
tf.keras.layers.Dense(m,n) # fully connected layer from
# m to n units
tf.keras.layers.ConvXd(m,n,s) # X dimensional conv layer from
# m to n channels where X⍷{1,2,3}
# and the kernel size is s
tf.keras.layers.MaxPoolXd(s) # X dimension pooling layer
# (notation as above)
tf.keras.layers.BatchNormalization # batch norm layer
tf.keras.layers.RNN/LSTM/GRU # recurrent layers
tf.keras.layers.Dropout(rate=0.5) # dropout layer for any dimensional input
tf.keras.layers.Embedding(input_dim, output_dim) # (tensor-wise) mapping from
# indices to embedding vectors
```
### Loss Functions
```
tf.keras.losses.X # where X is BinaryCrossentropy, BinaryFocalCrossentropy, CTC
# CategoricalCrossentropy, CategoricalFocalCrossentropy,
# CategoricalHinge, CosineSimilarity, Dice, Hinge, Huber
# KLDivergence, LogCosh, MeanAbsoluteError, MeanAbsolutePercentageError
# MeanSquaredError, MeanSquaredLogarithmicError, Poisson
# Reduction, SparseCategoricalCrossentropy, SquaredHinge, Tversky
```
### Activation Functions
```
tf.keras.activations.X # where X is ReLU, ReLU6, ELU, SELU, PReLU, LeakyReLU,
# RReLu, CELU, GELU, Threshold, Hardshrink, HardTanh,
# Sigmoid, LogSigmoid, Softplus, SoftShrink,
# Softsign, Tanh, TanhShrink, Softmin, Softmax,
# Softmax2d, LogSoftmax or AdaptiveSoftmaxWithLoss
```
### Optimizers
```
opt = tf.keras.optimizer.x(model.parameters(), ...) # create optimizer
opt.step() # update weights
optim.X # where X is SGD, Adadelta, Adafactor,
# Adagrad, Adam, AdamW, Adamax, Ftrl, Lion,
# LossScaleOptimizer ,RMSprop or Rprop
```
### Learning rate scheduling - Callbacks
```
callbacks = tf.keras.callbacks.LearningRateScheduler(scheduler) # create lr scheduler
model.fit(..., callbacks=[callback], ....) # update lr after optimizer updates weights
# using with fit(), evaluate(), and predict()
```
### Saving and Loading Models
```
tf.keras.models.clone_model(...) # Clone a Functional or Sequential Model instance.
tf.keras.models.load_model(...) # Loads a model saved via model.save().
tf.keras.models.model_from_json(...) # Parses a JSON model configuration string and returns a model instance.
tf.keras.models.save_model(...) # Saves a model as a .keras file.
```
## Data Utilities { .cols-1 }
### Datasets
```
pip install tensorflow-datasets # install the module
tfds.load('mnist', split, shuffle_files) # loading a dataset
```