This file contains 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
use async_openai::{Client, types::{CreateCompletionRequestArgs}}; | |
pub struct OpenAi { | |
client: Client, | |
model: String, | |
max_tokens: u16, | |
} | |
impl OpenAi { | |
pub fn new(model: String, max_tokens: u16) -> Self { |
This file contains 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
use app::openai::OpenAi; | |
#[tokio::test] | |
async fn test_openai() { | |
let input_text = "Hello, world!"; | |
let client = OpenAi::new("text-davinci-003".to_string(), 400_u16); | |
let response_text = client.ask(input_text).await; | |
assert!( | |
response_text.contains(input_text), | |
"Expected '{}' to contain '{}'", |
This file contains 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
x := x - \frac{\partial}{\partial x}J(x, y) \\ | |
y := y - \frac{\partial}{\partial y}J(x, y) \\ |
This file contains 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
err(h_\theta(x), y) = \left\{ | |
\begin{array}{ll} | |
1 & (h_\theta(x) \geq 0.5, y = 0 \quad or \quad h_\theta(x) \lt 0.5, y = 1) \\ | |
0 & (otherwise) | |
\end{array} | |
\right. |
This file contains 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
hx = X * theta; | |
cost = hx - y; | |
theta = [0; theta(2:end, :)]; | |
J = ((cost' * cost) + lambda * (theta' * theta)) / (2 * m); |
This file contains 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
a = [1, 2, 3] | |
b = [2, 3, 4] | |
ans = 0 | |
for i, v in enumerate(a): | |
ans = ans + a[i] * b[i] | |
print(ans) |
This file contains 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
以下の三角形の頂点から下まで移動するとき, その数値の和の最大値は23になる. | |
3 | |
7 4 | |
2 4 6 | |
8 5 9 3 | |
この例では 3 + 7 + 4 + 9 = 23. | |
以下の三角形を頂点から下まで移動するとき, その最大の和を求めよ. |
This file contains 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 sys | |
class Problem17: | |
COUNT = { | |
0: '', | |
1: 'one', | |
2: 'two', | |
3: 'three', |
This file contains 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 sys | |
class Problem16: | |
def main(self, n): | |
return sum(int(i) for i in str(2 ** n)) | |
if __name__ == '__main__': |
This file contains 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 sys | |
class Problem15: | |
def main(self, n): | |
tensor = [list(range(n + 1)) for i in range(n + 1)] | |
for i in range(n + 1): | |
for j in range(n + 1): | |
if i > 0 and j > 0: |
NewerOlder