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 Cocoa | |
| //No bounds checking | |
| struct Matrix { | |
| let dims:[Int] | |
| let increaseDim:[Int] | |
| var grid: [Double] | |
| init(dim: Int...) { | |
| self.dims = dim | |
| var tmpInDim:[Int] = [1] |
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 Accelerate | |
| //Perform a 3x3 matrix production, axb | |
| var a:[Double] = [1,1,0, 0,1,0, 0,0,1] | |
| var b:[Double] = [1,2,3, 4,5,6, 7,8,9] | |
| //Swift cannot understand LA constants, need to cast them | |
| var aObj:la_object_t = la_matrix_from_double_buffer(&a, 3, 3, 3, la_hint_t(LA_NO_HINT), la_attribute_t(LA_DEFAULT_ATTRIBUTES)) | |
| var bObj:la_object_t = la_matrix_from_double_buffer(&b, 3, 3, 3, la_hint_t(LA_NO_HINT), la_attribute_t(LA_DEFAULT_ATTRIBUTES)) |
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
| # Contrastive Loss | |
| # by Che-Wei Lin | |
| # Under the Simplified BSD License | |
| import tensorflow as tf | |
| from tensorflow.python.framework.function import Defun | |
| def contrastive_loss(margin, threshold=1e-5): | |
| """Contrastive loss: |
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
| # python3 | |
| import random | |
| import argparse | |
| if __name__ == '__main__': | |
| parser = argparse.ArgumentParser() | |
| parser.add_argument('-d', '--draw_cards_number', type=int, default=3) | |
| parser.add_argument('-i', '--iteration', type=int, default=100000) | |