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
using MXNet | |
import MXNet.mx: _update_single_output, reset!, get | |
using Distributions | |
##################################### | |
# Custom evaluation metric | |
# It just summarize predictions, because in the case of custom | |
# loss layer, ANN output equals to loss function itself |
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
using MXNet | |
import MXNet.mx: _update_single_output, reset!, get | |
using Distributions | |
# This example based on | |
# http://deeplearning.net/software/theano/tutorial/examples.html#a-real-example-logistic-regression | |
##################################### | |
# Custom evaluation metric |
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
# There is no default parse(Float16), this one is taken from | |
# https://github.com/JuliaLang/julia/issues/16411#issuecomment-256835385 | |
import Base: parse | |
function parse(::Type{Float16}, str::String) | |
fp = 0.0 | |
try | |
fp = parse(Float64, str) | |
catch | |
throw(ArgumentError(string("invalid number format \"",str,"\" for Float16"))) |
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
using BenchmarkTools | |
# Prepare random dictionary | |
d = Dict{Symbol, Real}() | |
for _ in 1:1000 | |
d[Symbol(randstring())] = rand() | |
end | |
function test_dict() | |
Dict(k => v for (k, v) in d) |
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
# https://github.com/dmlc/MXNet.jl/issues/167 | |
using MXNet | |
# Custom eval metric | |
import MXNet.mx: get, reset!, _update_single_output | |
type CustomMetric <: mx.AbstractEvalMetric | |
loss::Float64 | |
n::Int |
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
# | |
# This is a Shiny web application. You can run the application by clicking | |
# the 'Run App' button above. | |
# | |
# Find out more about building applications with Shiny here: | |
# | |
# http://shiny.rstudio.com/ | |
# | |
library(shiny) |
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
mutable struct Code | |
code::Vector{Int} | |
cur::Int | |
input::Int | |
output::Int | |
eop::Bool | |
end | |
str2prog(s) = parse.(Int, split(s, ",")) |
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
## Part 1 | |
function conv2graph(data) | |
graph = Dict{String, Vector{String}}() # x is being orbited by [y, z] | |
for orbit in data | |
m = match(r"^([^\)]+)\)(.*)$", orbit) | |
if m[1] in keys(graph) | |
push!(graph[m[1]], m[2]) | |
else | |
graph[m[1]] = [m[2]] | |
end |
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
struct PermIter{T} | |
v::Vector{T} | |
infinite::Bool | |
end | |
function Base.iterate(iter::PermIter{T}, state = ones(Int, length(iter.v))) where T | |
if state[end] == 2 return nothing end | |
v = iter.v | |
elem = Vector{T}(undef, length(iter.v)) |
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
mutable struct Prog | |
code::Vector{Int} | |
cur::Int | |
input::Vector{Int} | |
output::Vector{Int} | |
relative_base::Int | |
eop::Bool | |
end | |
str2prog(s) = parse.(Int, split(s, ",")) |
OlderNewer