Created
November 9, 2021 20:36
-
-
Save gallettilance/a85f852b1c9f9143e8d1af63253f40e0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import numpy as np | |
| from tensorflow import keras, norm | |
| RANK = 10 | |
| def custom_loss(y_true, y_pred): | |
| return norm(y_true - y_pred, ord='euclidean') | |
| boat = np.loadtxt('boat.dat') | |
| model = keras.models.Sequential() | |
| model.add(keras.layers.Dense(RANK, use_bias=False, input_dim=len(boat))) | |
| model.add(keras.layers.Dense(len(boat), use_bias=False)) | |
| model.compile(loss=custom_loss) | |
| history = model.fit(boat, boat, batch_size=50, epochs=500) | |
| rank_k_boat_approx = model.predict(boat) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment