forked from SciSharp/TensorFlow.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKwArgs.cs
More file actions
43 lines (37 loc) · 991 Bytes
/
KwArgs.cs
File metadata and controls
43 lines (37 loc) · 991 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using System;
using System.Collections.Generic;
using System.Text;
namespace Tensorflow.Keras
{
public class KwArgs
{
private Dictionary<string, object> args = new Dictionary<string, object>();
public object this[string name]
{
get
{
return args.ContainsKey(name) ? args[name] : null;
}
set
{
args[name] = value;
}
}
public T Get<T>(string name)
{
if (!args.ContainsKey(name))
return default(T);
return (T)args[name];
}
public static explicit operator KwArgs(ValueTuple<string, object>[] p)
{
KwArgs kwArgs = new KwArgs();
kwArgs.args = new Dictionary<string, object>();
foreach (var item in p)
{
kwArgs.args[item.Item1] = item.Item2;
}
return kwArgs;
}
}
}