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 PuLP | |
| from pulp import * | |
| # Create the 'prob' variable to contain the problem data | |
| prob = LpProblem("The Miracle Worker", LpMaximize) | |
| # Create problem variables | |
| x=LpVariable("Medicine_1_units",0,None,LpInteger) | |
| y=LpVariable("Medicine_2_units",0, None, LpInteger) |
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
| # The status of the solution is printed to the screen | |
| print("Status:", LpStatus[prob.status]) | |
| # Output= | |
| # Status: Optimal | |
| # Each of the variables is printed with it's resolved optimum value | |
| for v in prob.variables(): | |
| print(v.name, "=", v.varValue) | |
| # Output= | |
| # Medicine_1_units = 3.0 |
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
| def fib(n): | |
| if n == 0: | |
| return 0 | |
| elif n == 1: | |
| return 1 | |
| else: | |
| return fib(n-1) + fib(n-2) |
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
| memory = {0: 0, 1: 1} | |
| def fib(n): | |
| if n in memory.keys(): | |
| return(memory[n]) | |
| else: | |
| memory[n] = fib(n-1) + fib(n-2) | |
| return memory[n] |
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 | |
| def editdistance(str1, str2): | |
| # define | |
| m, n = len(str1) + 1, len(str2) + 1 | |
| table = np.empty([m, n]) | |
| for i in range(m): | |
| table[i, 0] = i | |
| for j in range(n): | |
| table[0, j] = j | |
| for i in range(1, m): |
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
| # Libraries | |
| import time | |
| # Points | |
| p = [{"x" : 100, "y" : 300}, {"x" : 500, "y" : 100}, {"x" : 700, "y" : 300}] | |
| # default values | |
| prev_x = p[0]['x'] | |
| prev_y = p[0]['y'] | |
| t = 0 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
| #!/usr/bin/env python3 | |
| """ | |
| Script to test the size of saved models with different LoRA configurations: | |
| 1. Normal LoRA (attention layers only) | |
| 2. LoRA with embedding space adapter (modules_to_save) | |
| 3. LoRA with trainable_token_indices (specific token indices) | |
| 4. LoRA with new tokens added (train only new tokens) | |
| Requirements: | |
| pip install transformers peft torch |