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 os | |
| import json | |
| import sys | |
| import torch | |
| import glob | |
| def load_parameters(directory): | |
| """ Load model parameters from a JSON file. """ | |
| with open(os.path.join(directory, 'params.json'), 'r') as file: | |
| return json.load(file) |
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
| { | |
| "last_node_id": 3, | |
| "last_link_id": 2, | |
| "nodes": [ | |
| { | |
| "id": 2, | |
| "type": "Call LLM Basic", | |
| "pos": [ | |
| 42, | |
| 190 |
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
| # QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals. | |
| # Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation. | |
| # | |
| # Licensed under the Apache License, Version 2.0 (the "License"); | |
| # you may not use this file except in compliance with the License. | |
| # You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 | |
| # | |
| # Unless required by applicable law or agreed to in writing, software | |
| # distributed under the License is distributed on an "AS IS" BASIS, | |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
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 scala.concurrent.{ExecutionContext, Future} | |
| trait Retryable { | |
| // Returning T, throwing the exception on failure | |
| @annotation.tailrec | |
| final def retryDangerously[T](n: Int)(fn: => T): T = { | |
| util.Try { fn } match { | |
| case util.Success(x) => x | |
| case _ if n > 1 => retryDangerously(n - 1)(fn) | |
| case util.Failure(e) => throw e |
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
| AsyncTask<Void, Void, String> task = new AsyncTask<Void, Void, String>() { | |
| @Override | |
| protected String doInBackground(Void... params) { | |
| AdvertisingIdClient.Info idInfo = null; | |
| try { | |
| idInfo = AdvertisingIdClient.getAdvertisingIdInfo(getApplicationContext()); | |
| } catch (GooglePlayServicesNotAvailableException e) { | |
| e.printStackTrace(); | |
| } catch (GooglePlayServicesRepairableException e) { | |
| e.printStackTrace(); |
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
| /** | |
| * Exercise 3 | |
| */ | |
| def countChange(money: Int, coins: List[Int]): Int = { | |
| def count(m: Int, sortedCoins: List[Int]) : Int = { | |
| if (sortedCoins.isEmpty) 0 | |
| else if (m - sortedCoins.head == 0) 1 | |
| else if (m - sortedCoins.head < 0) 0 | |
| else countChange(m - sortedCoins.head, sortedCoins) + countChange(m, sortedCoins.tail) | |
| } |
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 balance(chars: List[Char]): Boolean = { | |
| def balanced(chars: List[Char], currently_open_parens: Int): Boolean = { | |
| if (chars.isEmpty) currently_open_parens == 0 | |
| else { | |
| if(chars.head == '(') balanced(chars.tail, currently_open_parens+1) | |
| else { | |
| if(chars.head == ')' ) { | |
| currently_open_parens > 0 && balanced(chars.tail, currently_open_parens-1) | |
| } else balanced(chars.tail, currently_open_parens) | |
| } |