This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
public enum QueueType { | |
case lifo | |
} | |
public class Queue<T> { | |
var maxSize: Int? = nil | |
var elements: Array<T> = [] | |
var type: QueueType = QueueType.lifo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import Python | |
import TensorFlow | |
public struct MyModel : Layer { | |
public var conv1d: Conv1D<Float> | |
public var dense1: Dense<Float> | |
public var dropout: Dropout<Float> | |
public var denseOut: Dense<Float> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
public extension Array where Element == String { | |
@discardableResult | |
func exec() -> String { | |
joined(separator: " ").exec() | |
} | |
} | |
public extension String { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import Logging | |
import S3 | |
let LOGGER = Logger(label: "S3") | |
enum S3Error: Error { | |
case runtimeError(String) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public extension Dictionary { | |
/// - Parameter key: Key to retrieve from self. | |
/// - Parameter or: Value that will be set for `key` if `self[key]` is nil. | |
subscript(key: Key, or def: Value) -> Value { | |
mutating get { | |
self[key] ?? { | |
self[key] = def | |
return def | |
}() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM ubuntu:20.04 | |
RUN apt-get update \ | |
&& apt-get upgrade -y | |
RUN apt-get install -y curl scala | |
WORKDIR /src |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM ubuntu:20.04 | |
RUN apt-get update \ | |
&& apt-get upgrade -y | |
RUN apt-get install -y curl | |
RUN cd /root \ | |
&& curl -Lo cs https://git.io/coursier-cli-linux \ | |
&& chmod +x cs \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def criterion(x1, x2, label, margin: float = 1.0): | |
""" | |
Computes Contrastive Loss | |
""" | |
dist = torch.nn.functional.pairwise_distance(x1, x2) | |
loss = (1 - label) * torch.pow(dist, 2) \ | |
+ (label) * torch.pow(torch.clamp(margin - dist, min=0.0), 2) | |
loss = torch.mean(loss) |