Skip to content

Instantly share code, notes, and snippets.

View Dapid's full-sized avatar

David Menéndez Hurtado Dapid

  • Savantic AB
  • Stockholm
View GitHub Profile
import numpy as np
import keras_cv
model = keras_cv.models.RetinaNet(backbone=keras_cv.models.MobileNetV3Backbone.from_preset('mobilenet_v3_small_imagenet'),
num_classes=2,
bounding_box_format="xywh",
)
image= np.random.randint(0, 255, size=(1, 640, 480, 3), dtype=np.uint8)
model(image)
import numpy as np
import scipy.optimize as spo
import scipy.stats as sps
import matplotlib.pyplot as plt
x, y = np.array([[3.16275414, 3.79136358],
[3.06332232, 3.56686702],
[2.71045949, 3.65764056],
[3.31620986, 3.9009491 ],
[3.0538026 , 3.77374607],
@Dapid
Dapid / tensordot_layer.py
Last active July 17, 2022 15:29
Tensordot-style layer for Keras
from __future__ import division
import collections
from keras import backend as K
from keras import activations, initializations, regularizers, constraints
from keras.engine import InputSpec
from keras.engine.topology import Layer
class Tensordot(Layer):
import pandas as pd
import pylab as plt
df_allcauses = pd.read_excel('datasetfinalcorrected3.xlsx', sheet_name='Table 2', header=4, nrows=38)
df_covid = pd.read_excel('datasetfinalcorrected3.xlsx', sheet_name='Table 1', header=4, nrows=38)
for k in df_covid.keys():
if k.startswith('Age-st'):
df_covid[k] = pd.to_numeric(df_covid[k], errors='coerce').fillna(0)
import numpy as np
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
import cartopy.feature as cfeature
lon = 10 + 15 * np.random.random(30)
lat = 55 + 15 * np.random.random(30)
data = np.random.randn(30)
# Run this to get the example file
import tables
import numpy as np
h5 = tables.open_file('onefile.h5', 'w', filters=tables.Filters(8, 'lzo'))
g = h5.create_group(h5.root, 'data')
h5.create_carray(g, 'data_array', obj=np.random.random((int(1e6), 20)))
h5.close()
[Version]
AppVersion=5.7
Version=346
[General]
Rank=-1
ColorLabel=0
InTrash=false
[Exposure]
@Dapid
Dapid / amazing_grace.ly
Last active December 18, 2019 09:03
Latex-lily example
\version "2.19.83"
\language "espanol"
\header {
title = "Amazing Grace"
composer = "Trad. Scottish"
%tagline = ""
}
@Dapid
Dapid / code.py
Created December 11, 2019 20:59
HadCRUT analysis
import numpy as np
import netCDF4 as nc
from scipy import stats
import pylab as plt
import seaborn as sns
rootgrp = nc.Dataset('HadCRUT.4.6.0.0.median.nc')
t = rootgrp['time'][:] / 365 + 1850
import os
# os.environ['CUDA_VISIBLE_DEVICES'] = '1'
import time
import numpy
import jax.numpy as np
from jax import random, grad, jit