Word Embedding Castellano:
1 2 |
import tensorflow as tf tf.config.list_physical_devices() |
1 2 |
from tensorflow.python.client import device_lib device_lib.list_local_devices() |
1 2 3 |
device = device_lib.list_local_devices()[ 0 ] with tf.device(device.name): history = model.fit(x, y,epochs = epochs,verbose = False ) |
1 2 3 4 5 6 7 8 9 10 11 |
poetry config virtualenvs. in - project true poetry config - - list #se debe instalar siempre esta dependencia poetry add ipykernel #instalar poetry install #ejecutar código python poetry run python my_script.py |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
from matplotlib.colors import LinearSegmentedColormap, to_rgb def crear_colomap_continuo(hex_colors): all_red = [] all_green = [] all_blue = [] for hex_color in hex_colors: all_red.append(to_rgb(hex_color)[ 0 ]) all_green.append(to_rgb(hex_color)[ 1 ]) all_blue.append(to_rgb(hex_color)[ 2 ]) num_colors = len (hex_colors) - 1 red = tuple ([( 1 / num_colors * i,v,v) for i,v in enumerate (all_red)]) green = tuple ([( 1 / num_colors * i,v,v) for i,v in enumerate (all_green)]) blue = tuple ([( 1 / num_colors * i,v,v) for i,v in enumerate (all_blue)]) color_dictionary = { 'red' :red, 'green' :green, 'blue' :blue} new_cmap = LinearSegmentedColormap( 'new_cmap' ,segmentdata = color_dictionary) return new_cmap new_cmap = build_custom_continuous_cmap([ "#FFFFFF" , "#DBE6FA" , "#C3D6F4" , "#ACC8EF" , "#96BBE9" , "#81AFE4" , "#6DA4DE" , "#599BD9" , "#4793D3" , "#358CCE" , "#2486C8" , "#1481C3" , "#057DBD" ]) |