Download capas.py from rmontero/capas: direct link, hf CLI and curl.
- Browser
- Download file 1.38 kB
-
https://huggingface.co/rmontero/capas/resolve/main/capas.py
- Command line
-
hf download hf://rmontero/capas/capas.py
-
curl -L -o capas.py https://huggingface.co/rmontero/capas/resolve/main/capas.py
1.38 kB
| import tensorflow as tf | |
| import numpy as np | |
| from tensorflow.keras import layers | |
| #from tensorflow.keras.layers.experimental import preprocessing | |
| import tensorflow.keras as kr | |
| #import scipy as sc | |
| #import matplotlib.pyplot as plt | |
| X = np.array([0,2,4]) | |
| Y = np.array([0,2,4]) | |
| Z = np.array([[0]]) | |
| # Make numpy values easier to read. | |
| np.set_printoptions(precision=1, suppress=True) | |
| lr = 0.01 # learning rate | |
| nn = [1, 12, 16, 1] # número de neuronas por capa. | |
| # Creamos el objeto que contendrá a nuestra red neuronal, como | |
| # secuencia de capas. | |
| capa_0 = layers.Dense(1, activation="relu"); | |
| model = tf.keras.Sequential([ | |
| layers.Dense(nn[0], activation='sigmoid'), | |
| layers.Dense(nn[1], activation='relu'), | |
| layers.Dense(nn[2], activation='relu'), | |
| layers.Dense(nn[3], activation='sigmoid') | |
| ]) | |
| # Compilamos el modelo, definiendo la función de coste y el optimizador. | |
| model.compile(loss='mse', optimizer=kr.optimizers.SGD(lr=0.01), metrics=['acc']) | |
| # model.compile(loss='mse', optimizer = tf.optimizers.Adam(), metrics=['acc']) | |
| print("Y entrenamos al modelo. Los callbacks") | |
| # Y entrenamos al modelo. Los callbacks | |
| model.fit(X, Y, epochs=100, verbose=1) | |
| valor =1 | |
| while valor!=0: | |
| print("Ingresa un valor para predecir") | |
| valor =int(input("z=")) | |
| Z[[0]] =valor | |
| print(model.predict(Z)) |