forked from dotnet/TorchSharp
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathLambda.cs
38 lines (33 loc) · 1.03 KB
/
Lambda.cs
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
// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. See LICENSE in the project root for license information.
using System;
using static TorchSharp.torch;
namespace TorchSharp
{
public static partial class torchvision
{
internal class Lambda : ITransform
{
internal Lambda(Func<Tensor, Tensor> lambda)
{
this.lambda = lambda;
}
public Tensor call(Tensor img)
{
return lambda(img);
}
private Func<Tensor, Tensor> lambda;
}
public static partial class transforms
{
/// <summary>
/// Apply a user-defined function as a transform.
/// </summary>
/// <param name="lambda">Lambda/function to be used for transform.</param>
/// <returns></returns>
static public ITransform Lambda(Func<Tensor, Tensor> lambda)
{
return new Lambda(lambda);
}
}
}
}