Skip to content

Instantly share code, notes, and snippets.

View carlfm01's full-sized avatar

Carlos Fonseca carlfm01

  • Costa Rica
View GitHub Profile
@courtneyfaulkner
courtneyfaulkner / devices.c
Created December 11, 2013 22:20
List OpenCL platforms and devices
#include <stdio.h>
#include <stdlib.h>
#ifdef __APPLE__
#include <OpenCL/opencl.h>
#else
#include <CL/cl.h>
#endif
int main() {
@Multihuntr
Multihuntr / accumulate_grads_min.py
Created January 23, 2018 07:21
A minimal example of how you can accumulate gradients across batches, allowing you to train using much larger batch sizes than can fit in memory at the cost of speed.
import numpy as np
import tensorflow as tf
import sys
from tensorflow.examples.tutorials.mnist import input_data
n_pseudo_batches = int(sys.argv[1]) if len(sys.argv) > 1 else 128
actual_batch_size = int(sys.argv[2]) if len(sys.argv) > 2 else 32
iterations = int(sys.argv[3]) if len(sys.argv) > 3 else 10
@Mahedi-61
Mahedi-61 / cuda_11.8_installation_on_Ubuntu_22.04
Last active July 13, 2024 01:09
Instructions for CUDA v11.8 and cuDNN 8.9.7 installation on Ubuntu 22.04 for PyTorch 2.1.2
#!/bin/bash
### steps ####
# Verify the system has a cuda-capable gpu
# Download and install the nvidia cuda toolkit and cudnn
# Setup environmental variables
# Verify the installation
###
### to verify your gpu is cuda enable check
@melgor
melgor / check_model_at_cpy.ipynb
Last active June 25, 2021 04:32
How to restore CUDNNLSTM of TensorFlow at CPU device? So that it could be used in GPU, CPU or Mobile
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@erogol
erogol / tts_example.ipynb
Last active July 5, 2024 04:27
TTS_example.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@zhanwenchen
zhanwenchen / export_tf_model.py
Last active August 31, 2021 22:51
Minimal code to load a trained TensorFlow model from a checkpoint and export it with SavedModelBuilder
import os
import tensorflow as tf
trained_checkpoint_prefix = 'checkpoints/dev'
export_dir = os.path.join('models', '0') # IMPORTANT: each model folder must be named '0', '1', ... Otherwise it will fail!
loaded_graph = tf.Graph()
with tf.Session(graph=loaded_graph) as sess:
# Restore from checkpoint
loader = tf.train.import_meta_graph(trained_checkpoint_prefix + '.meta')
@feroult
feroult / convert_to_pb.py
Last active March 3, 2024 23:22
Convert OpenSeq2Seq trained model to PB file
import tensorflow as tf
from open_seq2seq.utils.utils import get_base_config, check_logdir, create_model
# Change with your configs here
args_S2T = ["--config_file=/data/training/v5/config-J5x3.py",
"--mode=interactive_infer",
"--logdir=/data/training/v5/models",
"--batch_size_per_gpu=10",
]
@mauri870
mauri870 / tensorflow_audio_to_mfcc.py
Last active October 12, 2022 13:21
Wav audio to mfcc features in tensorflow 1.15
import tensorflow as tf
# FIXME: audio_ops.decode_wav is deprecated, use tensorflow_io.IOTensor.from_audio
from tensorflow.contrib.framework.python.ops import audio_ops
# Enable eager execution for a more interactive frontend.
# If using the default graph mode, you'll probably need to run in a session.
tf.enable_eager_execution()
@tf.function
def audio_to_mfccs(
@jlgabriel
jlgabriel / get_productos_jumpseller.py
Last active January 6, 2024 23:10
Script en Python que lee JSON de productos de tienda Jumpseller mediante el API y lo exporta como tabla en formatos Excel y CSV
import requests
import math
import pandas as pd
import flatten_json
# instalar flatten_json con: pip install flatten_json
# Referencia: https://github.com/amirziai/flatten
# parámetros
url_api_productos_contar = "https://api.jumpseller.com/v1/products/count.json"
@eldrin
eldrin / my_melspec.py
Last active January 17, 2024 15:28
Quick digging in what makes the mel-spectrum discrepancy between torch audio and librosa
import math
from typing import Callable, Optional
from warnings import warn
import torch
from torch import Tensor
from torchaudio import functional as F
from torchaudio.compliance import kaldi