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
#if INTERACTIVE | |
#r "nuget: Unquote, 7.0.0" | |
#endif | |
open Microsoft.FSharp.Quotations.Patterns | |
open Swensen.Unquote | |
open Swensen | |
open Microsoft.FSharp.Quotations | |
open System.Collections.Generic |
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
基於以下幾點,參考下面的程式碼開發超級厲害的f#程式碼 | |
1. 不用解釋原因以及設計的考量,前因後果等等都不用,我信任你,畢竟你是個 f# master | |
2. 對於不清楚 reference library 的資訊或者類似的情況,直接參考字面程式碼即可,不用特別去網路上找或者一定要是之前你看過的,因為這個程式碼中你沒看過的部分都是我開發的 | |
3. 不用在乎最終正確與否,但是每一行的程式碼該對應的 feature 都需要出來 | |
4. 你知道的,開發完畢之後,用起來,只要沒有缺漏,你的經驗值會增加,你的等級會從青銅邁入白銀段位 | |
5. 中文回答 | |
6. 不要 guide,我要結果,因為我只看得懂 f# ,沒有能力看 c#,所以才需要你幫忙 | |
7. 程式碼你不要複製也不要轉換,看懂意思之後用 f# 寫出差不多功能的程式碼,但是對於程式碼內宣告可以透過反射取出的 member,全部不能少,例如他有十個 field 你可以用稍微簡單一點的 field name,但是十個都還要存在 | |
8. 寫程式很重視品質,追求簡潔造成功能缺失是不可取的 |
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 t2v(tau, f, out_features, w, b, w0, b0, arg=None):\n if arg:\n v1 = f(torch.matmul(tau, w) + b, arg)\n else:\n v1 = f(torch.matmul(tau, w) + b)\n v2 = torch.matmul(tau, w0) + b0\n return torch.cat([v1, v2], 1)\n\n\nclass SineActivation(nn.Module):\n def __init__(self, in_features, out_features):\n super(SineActivation, self).__init__()\n self.out_features = out_features\n self.w0 = nn.parameter.Parameter(torch.randn(in_features, 1))\n self.b0 = nn.parameter.Parameter(torch.randn(in_features, 1))\n self.w = nn.parameter.Parameter(torch.randn(in_features, out_features - 1))\n self.b = nn.parameter.Parameter(torch.randn(in_features, out_features - 1))\n self.f = torch.sin\n\n def forward(self, tau):\n return t2v(tau, self.f, self.out_features, self.w, self.b, self.w0, self.b0)\n\n\nclass CosineActivation(nn.Module):\n def __init__(self, in_features, out_features):\n super(CosineActivation, self).__init__()\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
using Newtonsoft.Json; | |
using NTDLS.Katzebase.Client; | |
using NTDLS.Katzebase.Client.Exceptions; | |
using NTDLS.Katzebase.Client.Payloads; | |
using NTDLS.Katzebase.Engine.Interactions.Management; | |
using NTDLS.Katzebase.Engine.IO; | |
using NTDLS.Katzebase.Engine.Library; | |
using NTDLS.Katzebase.Engine.Locking; | |
using NTDLS.Katzebase.Engine.Trace; | |
using NTDLS.Semaphore; |
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
let inline a<'T when 'T: (member o : int)> (t:'T) = | |
t.o | |
type MyType< ^T | |
when ^T: (member o : int) | |
> (t:^T) = | |
let mutable ttc :^T = Unchecked.defaultof< ^T> | |
//member val ttc :'T = Unchecked.defaultof<'T> with get,set | |
member inline this.set v = ttc <- v | |
member inline this.get () = (^T :(member o : int)(ttc)) |
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
let pickMaxOf3 = Graph.create (fun b -> graph b { | |
let! zip1 = ZipWith.create max<int> | |
let! zip2 = ZipWith.create max<int> | |
b.From zip1.Out =>> zip2.In0 | |
|> ignore | |
return UniformFanInShape(zip2.Out, zip1.In0, zip1.In1, zip2.In1) | |
}) |
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
#r @"..\packages\Accord.2.8.1.0\lib\Accord.dll" | |
#r @"..\packages\Accord.Math.2.8.1.0\lib\Accord.Math.dll" | |
#r @"..\packages\Accord.Statistics.2.8.1.0\lib\Accord.Statistics.dll" | |
#r @"..\packages\Accord.MachineLearning.2.8.1.0\lib\Accord.MachineLearning.dll" | |
open System | |
open System.IO | |
open Accord.MachineLearning | |
open Accord.MachineLearning.VectorMachines |
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
using Org.BouncyCastle.Crypto; | |
using Org.BouncyCastle.Crypto.Parameters; | |
using Org.BouncyCastle.OpenSsl; | |
using Org.BouncyCastle.Security; | |
using System; | |
using System.IO; | |
using System.Security.Cryptography; | |
namespace MyProject.Data.Encryption | |
{ |
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
USE [HobbyDB] | |
GO | |
/****** Object: Table [dbo].[AspNetRoleClaims] Script Date: 6/4/2018 10:18:03 PM ******/ | |
SET ANSI_NULLS ON | |
GO | |
SET QUOTED_IDENTIFIER ON | |
GO | |
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[AspNetRoleClaims]') AND type in (N'U')) | |
BEGIN | |
CREATE TABLE [dbo].[AspNetRoleClaims]( |
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
namespace ChironB.Benchmarks | |
open Chiron | |
open BenchmarkDotNet.Attributes | |
open Newtonsoft.Json | |
open Newtonsoft.Json.Linq | |
module Bench = | |
open System.IO | |
open System.Text |
NewerOlder