public void Infer(Logistic layer, LogisticLayerArgument argument, InferenceContext context) { var inputAlloc = context.MainMemoryMap[layer.Input.Connection.From]; var outputAlloc = context.MainMemoryMap[layer.Output]; argument.Flags = K210LayerFlags.MainMemoryOutput; argument.MainMemoryInputAddress = inputAlloc.GetAddress(); argument.MainMemoryOutputAddress = outputAlloc.GetAddress(); }
public void Forward(LogisticLayerArgument argument, ForwardContext context) { var src = MemoryMarshal.Cast <byte, float>(context.GetMainRamAt((int)argument.MainMemoryInputAddress)); var dest = MemoryMarshal.Cast <byte, float>(context.GetMainRamAt((int)argument.MainMemoryOutputAddress)); for (int oc = 0; oc < argument.Channels; oc++) { dest[oc] = 1f / (1f + (float)Math.Exp(-src[oc])); } }
public LogisticLayerArgument DeserializeBin(int offset, K210BinDeserializeContext context) { var sr = context.GetReaderAt(offset); var argument = new LogisticLayerArgument(); argument.Flags = sr.Read <K210LayerFlags>(); argument.MainMemoryInputAddress = sr.Read <uint>(); argument.MainMemoryOutputAddress = sr.Read <uint>(); argument.Channels = sr.Read <uint>(); return(argument); }