public void ThresholdLayer_ForwardWithConfiguration() { var config = new ThresholdLayerConfiguration(0.5f); var layer = new ThresholdLayer(config); layer.Setup(bottom, top); layer.Forward(bottom, top); Assert.Equal(bottom.Count, top.Count); using (var topCpu = top.OnCpu()) using (var bottomCpu = bottom.OnCpu()) { int count = bottom.Count; for (int i = 0; i < count; i++) { Assert.True(topCpu.DataAt(i) >= 0.0d); Assert.True(topCpu.DataAt(i) <= 1.0d); if (topCpu.DataAt(i) == 0.0d) { Assert.True(bottomCpu.DataAt(i) <= layer.Parameters.Threshold); } else if (topCpu.DataAt(i) == 1.0d) { Assert.True(bottomCpu.DataAt(i) > layer.Parameters.Threshold); } else { Assert.True(false); } } ; } }
public void ThresholdLayer_ForwardWithConfiguration() { var config = new ThresholdLayerConfiguration(0.5f); var layer = new ThresholdLayer(config); layer.Setup(bottom, top); layer.Forward(bottom, top); Assert.Equal(bottom.Count, top.Count); using (var topCpu = top.OnCpu()) using (var bottomCpu = bottom.OnCpu()) { int count = bottom.Count; for (int i = 0; i < count; i++) { Assert.True(topCpu.DataAt(i) >= 0.0d); Assert.True(topCpu.DataAt(i) <= 1.0d); if (topCpu.DataAt(i) == 0.0d) { Assert.True(bottomCpu.DataAt(i) <= layer.Parameters.Threshold); } else if (topCpu.DataAt(i) == 1.0d) { Assert.True(bottomCpu.DataAt(i) > layer.Parameters.Threshold); } else Assert.True(false); }; } }