Skip to content

Instantly share code, notes, and snippets.

View felipessalvatore's full-sized avatar

Felipe Salvatore felipessalvatore

View GitHub Profile
@felipessalvatore
felipessalvatore / tf_queue1.py
Last active September 28, 2017 15:18
Exploring queue tensorflow 1
import numpy as np
import tensorflow as tf
NUM_THREADS = 4
data = np.array([[0.2, 0.3], [0.4, 0.9], [0.8, -1.2], [-1.3, -0.2]])
target = np.array([1, 0, 1, 0])
queue = tf.FIFOQueue(capacity=3,
dtypes=[tf.float32, tf.int32],
@felipessalvatore
felipessalvatore / range_input_producer.py
Created September 29, 2017 17:24
script to grasp what the idea behind the range_input_producer
# range_input_producer(
# limit,
# num_epochs=None,
# shuffle=True,
# seed=None,
# capacity=32,
# shared_name=None,
# name=None)
# Produces the integers from 0 to limit-1 in a queue.
@felipessalvatore
felipessalvatore / strided_slice.py
Created September 29, 2017 18:46
tf_gist: strided_slice
# strided_slice(
# input_,
# begin,
# end,
# strides=None,
# begin_mask=0,
# end_mask=0,
# ellipsis_mask=0,
# new_axis_mask=0,
# shrink_axis_mask=0,
@felipessalvatore
felipessalvatore / points_with_label.py
Last active October 27, 2017 19:02
Plot points with numerical label in seaborn and latex title
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
from matplotlib import rc
sns.set_style("darkgrid")
# for using latex in plt it requires one installation:
# $ sudo apt install dvipng
rc('font', **{'family': 'sans-serif', 'sans-serif': ['Helvetica']})
@felipessalvatore
felipessalvatore / jupyter.md
Last active October 28, 2017 15:57
remote jupyter

Setting Jupyter in a remote computer

In REMOTE

i) create config file

$ jupyter notebook --generate-config

ii) create password

@felipessalvatore
felipessalvatore / lr_plot_ex.py
Created November 18, 2017 13:09
visual example of linear regression
from sklearn import linear_model
import numpy as np
import matplotlib.pyplot as plt
# generating fake linear data.
# Where x = square meter, y = house price
cond = False
while not cond:
@felipessalvatore
felipessalvatore / temporal_plot.py
Created December 17, 2017 14:28
Plotting a temporal series using matplotlib
import matplotlib.pyplot as plt
from datetime import date
#data
logic_tuple = [(1936, 3), (1937, 6), (1938, 3), (1939, 5),
(1940, 2), (1941, 2), (1942, 7), (1943, 1),
(1944, 2), (1945, 2), (1947, 2), (1948, 4),
(1949, 7), (1950, 3), (1951, 2), (1952, 5),
@felipessalvatore
felipessalvatore / ngram_overlap.py
Created December 18, 2017 17:00
using nltk to count N-gram overlap between two sentences
from nltk.translate.bleu_score import modified_precision
pt = "em plano aberto, a cidade parece linda"
ref = "in a wide shot, the city looks beautiful"
c1 = "in the open, the city looks beautiful"
c2 = "in open plan, the city looks gorgeous"
@felipessalvatore
felipessalvatore / write_img.py
Created February 7, 2018 20:26
write on image using cv2
import cv2
img = cv2.imread("0.png")
font = cv2.FONT_HERSHEY_PLAIN
bottomLeftCornerOfText = (15,25)
fontScale = 1
fontColor = (255,25,55)
lineType = 2
cv2.putText(img,"""up: 0.02""",
@felipessalvatore
felipessalvatore / revisao.txt
Last active March 17, 2018 19:51
links para revisão
Directional Derivative
http://tutorial.math.lamar.edu/Classes/CalcIII/DirectionalDeriv.aspx
https://www.ime.unicamp.br/~valle/Teaching/MA211/Aula6.pdf