Пример #1
0
        UnorderedMap <string, UnorderedSet <int> > FunctionsAcceptingNoneForIndicesMap()
        {
            var m = new UnorderedMap <string, UnorderedSet <int> >();

            m.Add("SoftmaxCrossEntropyWithLogits", new UnorderedSet <int>(new[] { 1 }));
            m.Add("SparseSoftmaxCrossEntropyWithLogits", new UnorderedSet <int>(new[] { 1 }));
            m.Add("FusedBatchNorm", new UnorderedSet <int>(new[] { 1, 2, 3, 4 }));
            return(m);
        }
        public Tensor[] TFE_TapeGradient(ITape tape,
                                         Tensor[] target,
                                         Tensor[] sources,
                                         Tensor[] output_gradients)
        {
            var target_vec  = MakeTensorIDList(target);
            var sources_vec = MakeTensorIDList(sources);
            var sources_set = sources_vec;

            var seq_array = target;
            var source_tensors_that_are_targets = new UnorderedMap <long, TapeTensor>();

            for (int i = 0; i < target.Length; ++i)
            {
                var target_id = target_vec[i];
                var tensor    = seq_array[i];
                source_tensors_that_are_targets.Add(target_id, TapeTensorFromTensor(tensor));
            }

            if (output_gradients != null)
            {
                throw new NotImplementedException("");
            }
            else
            {
                output_gradients = new Tensor[0];
            }

            var outgrad_vec = MakeTensorList(output_gradients);

            return(tape.ComputeGradient(target_vec, sources_vec, source_tensors_that_are_targets, outgrad_vec));
        }
Пример #3
0
 public static string Get(T value)
 {
     if (!map.TryGetValue(value, out string str))
     {
         str = value.ToString();
         map.Add(value, str);
     }
     return(str);
 }
Пример #4
0
 public void Add(TKey key, TValue value)
 {
     if (!keyToValue.ContainsKey(key))
     {
         keyToValue.Add(key, value);
     }
     if (!valueToKey.ContainsKey(value))
     {
         valueToKey.Add(value, key);
     }
 }
Пример #5
0
 static AttributedTypeCache()
 {
     foreach (var type in Meta.kumaAsms.AllTypes())
     {
         foreach (var attr in type.GetCustomAttributes())
         {
             if (!catalog.TryGetValue(attr.GetType(), out UnorderedSet <TypeKey> types))
             {
                 types = new UnorderedSet <TypeKey>(4);
                 catalog.Add(attr.GetType(), types);
             }
             types.AddIfNone(type);
         }
     }
 }