text:
using Compat
using ProtoBuf
import ProtoBuf.meta
import Base: hash, isequal, ==

type __enum_Phase <: ProtoEnum
    TRAIN::Int32
    TEST::Int32
    __enum_Phase() = new(0,1)
end #type __enum_Phase
const Phase = __enum_Phase()

type BlobShape
    dim::Array{Int64,1}
    BlobShape(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #type BlobShape
const __pack_BlobShape = Symbol[:dim]
meta(t::Type{BlobShape}) = meta(t, ProtoBuf.DEF_REQ, ProtoBuf.DEF_FNUM, ProtoBuf.DEF_VAL, true, __pack_BlobShape, ProtoBuf.DEF_WTYPES)
hash(v::BlobShape) = ProtoBuf.protohash(v)
isequal(v1::BlobShape, v2::BlobShape) = ProtoBuf.protoisequal(v1, v2)
==(v1::BlobShape, v2::BlobShape) = ProtoBuf.protoeq(v1, v2)

type BlobProto
    shape::BlobShape
    data::Array{Float32,1}
    diff::Array{Float32,1}
    double_data::Array{Float64,1}
    double_diff::Array{Float64,1}
    num::Int32
    channels::Int32
    height::Int32
    width::Int32
    BlobProto(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #type BlobProto
const __val_BlobProto = @compat Dict(:num => 0, :channels => 0, :height => 0, :width => 0)
const __fnum_BlobProto = Int[7,5,6,8,9,1,2,3,4]
const __pack_BlobProto = Symbol[:data,:diff,:double_data,:double_diff]
meta(t::Type{BlobProto}) = meta(t, ProtoBuf.DEF_REQ, __fnum_BlobProto, __val_BlobProto, true, __pack_BlobProto, ProtoBuf.DEF_WTYPES)
hash(v::BlobProto) = ProtoBuf.protohash(v)
isequal(v1::BlobProto, v2::BlobProto) = ProtoBuf.protoisequal(v1, v2)
==(v1::BlobProto, v2::BlobProto) = ProtoBuf.protoeq(v1, v2)

type BlobProtoVector
    blobs::Array{BlobProto,1}
    BlobProtoVector(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #type BlobProtoVector
hash(v::BlobProtoVector) = ProtoBuf.protohash(v)
isequal(v1::BlobProtoVector, v2::BlobProtoVector) = ProtoBuf.protoisequal(v1, v2)
==(v1::BlobProtoVector, v2::BlobProtoVector) = ProtoBuf.protoeq(v1, v2)

type Datum
    channels::Int32
    height::Int32
    width::Int32
    data::Array{UInt8,1}
    label::Int32
    float_data::Array{Float32,1}
    encoded::Bool
    Datum(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #type Datum
const __val_Datum = @compat Dict(:encoded => false)
meta(t::Type{Datum}) = meta(t, ProtoBuf.DEF_REQ, ProtoBuf.DEF_FNUM, __val_Datum, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES)
hash(v::Datum) = ProtoBuf.protohash(v)
isequal(v1::Datum, v2::Datum) = ProtoBuf.protoisequal(v1, v2)
==(v1::Datum, v2::Datum) = ProtoBuf.protoeq(v1, v2)

type __enum_FillerParameter_VarianceNorm <: ProtoEnum
    FAN_IN::Int32
    FAN_OUT::Int32
    AVERAGE::Int32
    __enum_FillerParameter_VarianceNorm() = new(0,1,2)
end #type __enum_FillerParameter_VarianceNorm
const FillerParameter_VarianceNorm = __enum_FillerParameter_VarianceNorm()

type FillerParameter
    _type::AbstractString
    value::Float32
    min::Float32
    max::Float32
    mean::Float32
    std::Float32
    sparse::Int32
    variance_norm::Int32
    FillerParameter(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #type FillerParameter
const __val_FillerParameter = @compat Dict(:_type => "constant", :value => 0, :min => 0, :max => 1, :mean => 0, :std => 1, :sparse => -1, :variance_norm => FillerParameter_VarianceNorm.FAN_IN)
meta(t::Type{FillerParameter}) = meta(t, ProtoBuf.DEF_REQ, ProtoBuf.DEF_FNUM, __val_FillerParameter, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES)
hash(v::FillerParameter) = ProtoBuf.protohash(v)
isequal(v1::FillerParameter, v2::FillerParameter) = ProtoBuf.protoisequal(v1, v2)
==(v1::FillerParameter, v2::FillerParameter) = ProtoBuf.protoeq(v1, v2)

type SolverState
    iter::Int32
    learned_net::AbstractString
    history::Array{BlobProto,1}
    current_step::Int32
    SolverState(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #type SolverState
const __val_SolverState = @compat Dict(:current_step => 0)
meta(t::Type{SolverState}) = meta(t, ProtoBuf.DEF_REQ, ProtoBuf.DEF_FNUM, __val_SolverState, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES)
hash(v::SolverState) = ProtoBuf.protohash(v)
isequal(v1::SolverState, v2::SolverState) = ProtoBuf.protoisequal(v1, v2)
==(v1::SolverState, v2::SolverState) = ProtoBuf.protoeq(v1, v2)

type NetState
    phase::Int32
    level::Int32
    stage::Array{AbstractString,1}
    NetState(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #type NetState
const __val_NetState = @compat Dict(:phase => Phase.TEST, :level => 0)
meta(t::Type{NetState}) = meta(t, ProtoBuf.DEF_REQ, ProtoBuf.DEF_FNUM, __val_NetState, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES)
hash(v::NetState) = ProtoBuf.protohash(v)
isequal(v1::NetState, v2::NetState) = ProtoBuf.protoisequal(v1, v2)
==(v1::NetState, v2::NetState) = ProtoBuf.protoeq(v1, v2)

type NetStateRule
    phase::Int32
    min_level::Int32
    max_level::Int32
    stage::Array{AbstractString,1}
    not_stage::Array{AbstractString,1}
    NetStateRule(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #type NetStateRule
hash(v::NetStateRule) = ProtoBuf.protohash(v)
isequal(v1::NetStateRule, v2::NetStateRule) = ProtoBuf.protoisequal(v1, v2)
==(v1::NetStateRule, v2::NetStateRule) = ProtoBuf.protoeq(v1, v2)

type __enum_ParamSpec_DimCheckMode <: ProtoEnum
    STRICT::Int32
    PERMISSIVE::Int32
    __enum_ParamSpec_DimCheckMode() = new(0,1)
end #type __enum_ParamSpec_DimCheckMode
const ParamSpec_DimCheckMode = __enum_ParamSpec_DimCheckMode()

type ParamSpec
    name::AbstractString
    share_mode::Int32
    lr_mult::Float32
    decay_mult::Float32
    ParamSpec(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #type ParamSpec
const __val_ParamSpec = @compat Dict(:lr_mult => 1, :decay_mult => 1)
meta(t::Type{ParamSpec}) = meta(t, ProtoBuf.DEF_REQ, ProtoBuf.DEF_FNUM, __val_ParamSpec, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES)
hash(v::ParamSpec) = ProtoBuf.protohash(v)
isequal(v1::ParamSpec, v2::ParamSpec) = ProtoBuf.protoisequal(v1, v2)
==(v1::ParamSpec, v2::ParamSpec) = ProtoBuf.protoeq(v1, v2)

type TransformationParameter
    scale::Float32
    mirror::Bool
    crop_size::UInt32
    mean_file::AbstractString
    mean_value::Array{Float32,1}
    force_color::Bool
    force_gray::Bool
    TransformationParameter(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #type TransformationParameter
const __val_TransformationParameter = @compat Dict(:scale => 1, :mirror => false, :crop_size => 0, :force_color => false, :force_gray => false)
meta(t::Type{TransformationParameter}) = meta(t, ProtoBuf.DEF_REQ, ProtoBuf.DEF_FNUM, __val_TransformationParameter, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES)
hash(v::TransformationParameter) = ProtoBuf.protohash(v)
isequal(v1::TransformationParameter, v2::TransformationParameter) = ProtoBuf.protoisequal(v1, v2)
==(v1::TransformationParameter, v2::TransformationParameter) = ProtoBuf.protoeq(v1, v2)

type __enum_LossParameter_NormalizationMode <: ProtoEnum
    FULL::Int32
    VALID::Int32
    BATCH_SIZE::Int32
    NONE::Int32
    __enum_LossParameter_NormalizationMode() = new(0,1,2,3)
end #type __enum_LossParameter_NormalizationMode
const LossParameter_NormalizationMode = __enum_LossParameter_NormalizationMode()

type LossParameter
    ignore_label::Int32
    normalization::Int32
    normalize::Bool
    LossParameter(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #type LossParameter
const __val_LossParameter = @compat Dict(:normalization => LossParameter_NormalizationMode.VALID)
const __fnum_LossParameter = Int[1,3,2]
meta(t::Type{LossParameter}) = meta(t, ProtoBuf.DEF_REQ, __fnum_LossParameter, __val_LossParameter, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES)
hash(v::LossParameter) = ProtoBuf.protohash(v)
isequal(v1::LossParameter, v2::LossParameter) = ProtoBuf.protoisequal(v1, v2)
==(v1::LossParameter, v2::LossParameter) = ProtoBuf.protoeq(v1, v2)

type AccuracyParameter
    top_k::UInt32
    axis::Int32
    ignore_label::Int32
    AccuracyParameter(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #type AccuracyParameter
const __val_AccuracyParameter = @compat Dict(:top_k => 1, :axis => 1)
meta(t::Type{AccuracyParameter}) = meta(t, ProtoBuf.DEF_REQ, ProtoBuf.DEF_FNUM, __val_AccuracyParameter, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES)
hash(v::AccuracyParameter) = ProtoBuf.protohash(v)
isequal(v1::AccuracyParameter, v2::AccuracyParameter) = ProtoBuf.protoisequal(v1, v2)
==(v1::AccuracyParameter, v2::AccuracyParameter) = ProtoBuf.protoeq(v1, v2)

type ArgMaxParameter
    out_max_val::Bool
    top_k::UInt32
    axis::Int32
    ArgMaxParameter(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #type ArgMaxParameter
const __val_ArgMaxParameter = @compat Dict(:out_max_val => false, :top_k => 1)
meta(t::Type{ArgMaxParameter}) = meta(t, ProtoBuf.DEF_REQ, ProtoBuf.DEF_FNUM, __val_ArgMaxParameter, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES)
hash(v::ArgMaxParameter) = ProtoBuf.protohash(v)
isequal(v1::ArgMaxParameter, v2::ArgMaxParameter) = ProtoBuf.protoisequal(v1, v2)
==(v1::ArgMaxParameter, v2::ArgMaxParameter) = ProtoBuf.protoeq(v1, v2)

type ConcatParameter
    axis::Int32
    concat_dim::UInt32
    ConcatParameter(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #type ConcatParameter
const __val_ConcatParameter = @compat Dict(:axis => 1, :concat_dim => 1)
const __fnum_ConcatParameter = Int[2,1]
meta(t::Type{ConcatParameter}) = meta(t, ProtoBuf.DEF_REQ, __fnum_ConcatParameter, __val_ConcatParameter, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES)
hash(v::ConcatParameter) = ProtoBuf.protohash(v)
isequal(v1::ConcatParameter, v2::ConcatParameter) = ProtoBuf.protoisequal(v1, v2)
==(v1::ConcatParameter, v2::ConcatParameter) = ProtoBuf.protoeq(v1, v2)

type BatchNormParameter
    use_global_stats::Bool
    moving_average_fraction::Float32
    eps::Float32
    BatchNormParameter(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #type BatchNormParameter
const __val_BatchNormParameter = @compat Dict(:moving_average_fraction => 0.999, :eps => 1e-05)
meta(t::Type{BatchNormParameter}) = meta(t, ProtoBuf.DEF_REQ, ProtoBuf.DEF_FNUM, __val_BatchNormParameter, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES)
hash(v::BatchNormParameter) = ProtoBuf.protohash(v)
isequal(v1::BatchNormParameter, v2::BatchNormParameter) = ProtoBuf.protoisequal(v1, v2)
==(v1::BatchNormParameter, v2::BatchNormParameter) = ProtoBuf.protoeq(v1, v2)

type BiasParameter
    axis::Int32
    num_axes::Int32
    filler::FillerParameter
    BiasParameter(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #type BiasParameter
const __val_BiasParameter = @compat Dict(:axis => 1, :num_axes => 1)
meta(t::Type{BiasParameter}) = meta(t, ProtoBuf.DEF_REQ, ProtoBuf.DEF_FNUM, __val_BiasParameter, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES)
hash(v::BiasParameter) = ProtoBuf.protohash(v)
isequal(v1::BiasParameter, v2::BiasParameter) = ProtoBuf.protoisequal(v1, v2)
==(v1::BiasParameter, v2::BiasParameter) = ProtoBuf.protoeq(v1, v2)

type ContrastiveLossParameter
    margin::Float32
    legacy_version::Bool
    ContrastiveLossParameter(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #type ContrastiveLossParameter
const __val_ContrastiveLossParameter = @compat Dict(:margin => 1, :legacy_version => false)
meta(t::Type{ContrastiveLossParameter}) = meta(t, ProtoBuf.DEF_REQ, ProtoBuf.DEF_FNUM, __val_ContrastiveLossParameter, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES)
hash(v::ContrastiveLossParameter) = ProtoBuf.protohash(v)
isequal(v1::ContrastiveLossParameter, v2::ContrastiveLossParameter) = ProtoBuf.protoisequal(v1, v2)
==(v1::ContrastiveLossParameter, v2::ContrastiveLossParameter) = ProtoBuf.protoeq(v1, v2)

type __enum_ConvolutionParameter_Engine <: ProtoEnum
    DEFAULT::Int32
    CAFFE::Int32
    CUDNN::Int32
    __enum_ConvolutionParameter_Engine() = new(0,1,2)
end #type __enum_ConvolutionParameter_Engine
const ConvolutionParameter_Engine = __enum_ConvolutionParameter_Engine()

type ConvolutionParameter
    num_output::UInt32
    bias_term::Bool
    pad::Array{UInt32,1}
    kernel_size::Array{UInt32,1}
    stride::Array{UInt32,1}
    dilation::Array{UInt32,1}
    pad_h::UInt32
    pad_w::UInt32
    kernel_h::UInt32
    kernel_w::UInt32
    stride_h::UInt32
    stride_w::UInt32
    group::UInt32
    weight_filler::FillerParameter
    bias_filler::FillerParameter
    engine::Int32
    axis::Int32
    force_nd_im2col::Bool
    ConvolutionParameter(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #type ConvolutionParameter
const __val_ConvolutionParameter = @compat Dict(:bias_term => true, :pad_h => 0, :pad_w => 0, :group => 1, :engine => ConvolutionParameter_Engine.DEFAULT, :axis => 1, :force_nd_im2col => false)
const __fnum_ConvolutionParameter = Int[1,2,3,4,6,18,9,10,11,12,13,14,5,7,8,15,16,17]
meta(t::Type{ConvolutionParameter}) = meta(t, ProtoBuf.DEF_REQ, __fnum_ConvolutionParameter, __val_ConvolutionParameter, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES)
hash(v::ConvolutionParameter) = ProtoBuf.protohash(v)
isequal(v1::ConvolutionParameter, v2::ConvolutionParameter) = ProtoBuf.protoisequal(v1, v2)
==(v1::ConvolutionParameter, v2::ConvolutionParameter) = ProtoBuf.protoeq(v1, v2)

type CropParameter
    axis::Int32
    offset::Array{UInt32,1}
    CropParameter(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #type CropParameter
const __val_CropParameter = @compat Dict(:axis => 2)
meta(t::Type{CropParameter}) = meta(t, ProtoBuf.DEF_REQ, ProtoBuf.DEF_FNUM, __val_CropParameter, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES)
hash(v::CropParameter) = ProtoBuf.protohash(v)
isequal(v1::CropParameter, v2::CropParameter) = ProtoBuf.protoisequal(v1, v2)
==(v1::CropParameter, v2::CropParameter) = ProtoBuf.protoeq(v1, v2)

type __enum_DataParameter_DB <: ProtoEnum
    LEVELDB::Int32
    LMDB::Int32
    __enum_DataParameter_DB() = new(0,1)
end #type __enum_DataParameter_DB
const DataParameter_DB = __enum_DataParameter_DB()

type DataParameter
    source::AbstractString
    batch_size::UInt32
    rand_skip::UInt32
    backend::Int32
    scale::Float32
    mean_file::AbstractString
    crop_size::UInt32
    mirror::Bool
    force_encoded_color::Bool
    prefetch::UInt32
    DataParameter(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #type DataParameter
const __val_DataParameter = @compat Dict(:rand_skip => 0, :backend => DataParameter_DB.LEVELDB, :scale => 1, :crop_size => 0, :mirror => false, :force_encoded_color => false, :prefetch => 4)
const __fnum_DataParameter = Int[1,4,7,8,2,3,5,6,9,10]
meta(t::Type{DataParameter}) = meta(t, ProtoBuf.DEF_REQ, __fnum_DataParameter, __val_DataParameter, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES)
hash(v::DataParameter) = ProtoBuf.protohash(v)
isequal(v1::DataParameter, v2::DataParameter) = ProtoBuf.protoisequal(v1, v2)
==(v1::DataParameter, v2::DataParameter) = ProtoBuf.protoeq(v1, v2)

type DropoutParameter
    dropout_ratio::Float32
    DropoutParameter(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #type DropoutParameter
const __val_DropoutParameter = @compat Dict(:dropout_ratio => 0.5)
meta(t::Type{DropoutParameter}) = meta(t, ProtoBuf.DEF_REQ, ProtoBuf.DEF_FNUM, __val_DropoutParameter, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES)
hash(v::DropoutParameter) = ProtoBuf.protohash(v)
isequal(v1::DropoutParameter, v2::DropoutParameter) = ProtoBuf.protoisequal(v1, v2)
==(v1::DropoutParameter, v2::DropoutParameter) = ProtoBuf.protoeq(v1, v2)

type DummyDataParameter
    data_filler::Array{FillerParameter,1}
    shape::Array{BlobShape,1}
    num::Array{UInt32,1}
    channels::Array{UInt32,1}
    height::Array{UInt32,1}
    width::Array{UInt32,1}
    DummyDataParameter(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #type DummyDataParameter
const __fnum_DummyDataParameter = Int[1,6,2,3,4,5]
meta(t::Type{DummyDataParameter}) = meta(t, ProtoBuf.DEF_REQ, __fnum_DummyDataParameter, ProtoBuf.DEF_VAL, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES)
hash(v::DummyDataParameter) = ProtoBuf.protohash(v)
isequal(v1::DummyDataParameter, v2::DummyDataParameter) = ProtoBuf.protoisequal(v1, v2)
==(v1::DummyDataParameter, v2::DummyDataParameter) = ProtoBuf.protoeq(v1, v2)

type __enum_EltwiseParameter_EltwiseOp <: ProtoEnum
    PROD::Int32
    SUM::Int32
    MAX::Int32
    __enum_EltwiseParameter_EltwiseOp() = new(0,1,2)
end #type __enum_EltwiseParameter_EltwiseOp
const EltwiseParameter_EltwiseOp = __enum_EltwiseParameter_EltwiseOp()

type EltwiseParameter
    operation::Int32
    coeff::Array{Float32,1}
    stable_prod_grad::Bool
    EltwiseParameter(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #type EltwiseParameter
const __val_EltwiseParameter = @compat Dict(:operation => EltwiseParameter_EltwiseOp.SUM, :stable_prod_grad => true)
meta(t::Type{EltwiseParameter}) = meta(t, ProtoBuf.DEF_REQ, ProtoBuf.DEF_FNUM, __val_EltwiseParameter, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES)
hash(v::EltwiseParameter) = ProtoBuf.protohash(v)
isequal(v1::EltwiseParameter, v2::EltwiseParameter) = ProtoBuf.protoisequal(v1, v2)
==(v1::EltwiseParameter, v2::EltwiseParameter) = ProtoBuf.protoeq(v1, v2)

type ELUParameter
    alpha::Float32
    ELUParameter(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #type ELUParameter
const __val_ELUParameter = @compat Dict(:alpha => 1)
meta(t::Type{ELUParameter}) = meta(t, ProtoBuf.DEF_REQ, ProtoBuf.DEF_FNUM, __val_ELUParameter, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES)
hash(v::ELUParameter) = ProtoBuf.protohash(v)
isequal(v1::ELUParameter, v2::ELUParameter) = ProtoBuf.protoisequal(v1, v2)
==(v1::ELUParameter, v2::ELUParameter) = ProtoBuf.protoeq(v1, v2)

type EmbedParameter
    num_output::UInt32
    input_dim::UInt32
    bias_term::Bool
    weight_filler::FillerParameter
    bias_filler::FillerParameter
    EmbedParameter(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #type EmbedParameter
const __val_EmbedParameter = @compat Dict(:bias_term => true)
meta(t::Type{EmbedParameter}) = meta(t, ProtoBuf.DEF_REQ, ProtoBuf.DEF_FNUM, __val_EmbedParameter, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES)
hash(v::EmbedParameter) = ProtoBuf.protohash(v)
isequal(v1::EmbedParameter, v2::EmbedParameter) = ProtoBuf.protoisequal(v1, v2)
==(v1::EmbedParameter, v2::EmbedParameter) = ProtoBuf.protoeq(v1, v2)

type ExpParameter
    base::Float32
    scale::Float32
    shift::Float32
    ExpParameter(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #type ExpParameter
const __val_ExpParameter = @compat Dict(:base => -1, :scale => 1, :shift => 0)
meta(t::Type{ExpParameter}) = meta(t, ProtoBuf.DEF_REQ, ProtoBuf.DEF_FNUM, __val_ExpParameter, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES)
hash(v::ExpParameter) = ProtoBuf.protohash(v)
isequal(v1::ExpParameter, v2::ExpParameter) = ProtoBuf.protoisequal(v1, v2)
==(v1::ExpParameter, v2::ExpParameter) = ProtoBuf.protoeq(v1, v2)

type FlattenParameter
    axis::Int32
    end_axis::Int32
    FlattenParameter(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #type FlattenParameter
const __val_FlattenParameter = @compat Dict(:axis => 1, :end_axis => -1)
meta(t::Type{FlattenParameter}) = meta(t, ProtoBuf.DEF_REQ, ProtoBuf.DEF_FNUM, __val_FlattenParameter, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES)
hash(v::FlattenParameter) = ProtoBuf.protohash(v)
isequal(v1::FlattenParameter, v2::FlattenParameter) = ProtoBuf.protoisequal(v1, v2)
==(v1::FlattenParameter, v2::FlattenParameter) = ProtoBuf.protoeq(v1, v2)

type HDF5DataParameter
    source::AbstractString
    batch_size::UInt32
    shuffle::Bool
    HDF5DataParameter(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #type HDF5DataParameter
const __val_HDF5DataParameter = @compat Dict(:shuffle => false)
meta(t::Type{HDF5DataParameter}) = meta(t, ProtoBuf.DEF_REQ, ProtoBuf.DEF_FNUM, __val_HDF5DataParameter, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES)
hash(v::HDF5DataParameter) = ProtoBuf.protohash(v)
isequal(v1::HDF5DataParameter, v2::HDF5DataParameter) = ProtoBuf.protoisequal(v1, v2)
==(v1::HDF5DataParameter, v2::HDF5DataParameter) = ProtoBuf.protoeq(v1, v2)

type HDF5OutputParameter
    file_name::AbstractString
    HDF5OutputParameter(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #type HDF5OutputParameter
hash(v::HDF5OutputParameter) = ProtoBuf.protohash(v)
isequal(v1::HDF5OutputParameter, v2::HDF5OutputParameter) = ProtoBuf.protoisequal(v1, v2)
==(v1::HDF5OutputParameter, v2::HDF5OutputParameter) = ProtoBuf.protoeq(v1, v2)

type __enum_HingeLossParameter_Norm <: ProtoEnum
    L1::Int32
    L2::Int32
    __enum_HingeLossParameter_Norm() = new(1,2)
end #type __enum_HingeLossParameter_Norm
const HingeLossParameter_Norm = __enum_HingeLossParameter_Norm()

type HingeLossParameter
    norm::Int32
    HingeLossParameter(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #type HingeLossParameter
const __val_HingeLossParameter = @compat Dict(:norm => HingeLossParameter_Norm.L1)
meta(t::Type{HingeLossParameter}) = meta(t, ProtoBuf.DEF_REQ, ProtoBuf.DEF_FNUM, __val_HingeLossParameter, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES)
hash(v::HingeLossParameter) = ProtoBuf.protohash(v)
isequal(v1::HingeLossParameter, v2::HingeLossParameter) = ProtoBuf.protoisequal(v1, v2)
==(v1::HingeLossParameter, v2::HingeLossParameter) = ProtoBuf.protoeq(v1, v2)

type ImageDataParameter
    source::AbstractString
    batch_size::UInt32
    rand_skip::UInt32
    shuffle::Bool
    new_height::UInt32
    new_width::UInt32
    is_color::Bool
    scale::Float32
    mean_file::AbstractString
    crop_size::UInt32
    mirror::Bool
    root_folder::AbstractString
    ImageDataParameter(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #type ImageDataParameter
const __val_ImageDataParameter = @compat Dict(:batch_size => 1, :rand_skip => 0, :shuffle => false, :new_height => 0, :new_width => 0, :is_color => true, :scale => 1, :crop_size => 0, :mirror => false)
const __fnum_ImageDataParameter = Int[1,4,7,8,9,10,11,2,3,5,6,12]
meta(t::Type{ImageDataParameter}) = meta(t, ProtoBuf.DEF_REQ, __fnum_ImageDataParameter, __val_ImageDataParameter, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES)
hash(v::ImageDataParameter) = ProtoBuf.protohash(v)
isequal(v1::ImageDataParameter, v2::ImageDataParameter) = ProtoBuf.protoisequal(v1, v2)
==(v1::ImageDataParameter, v2::ImageDataParameter) = ProtoBuf.protoeq(v1, v2)

type InfogainLossParameter
    source::AbstractString
    InfogainLossParameter(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #type InfogainLossParameter
hash(v::InfogainLossParameter) = ProtoBuf.protohash(v)
isequal(v1::InfogainLossParameter, v2::InfogainLossParameter) = ProtoBuf.protoisequal(v1, v2)
==(v1::InfogainLossParameter, v2::InfogainLossParameter) = ProtoBuf.protoeq(v1, v2)

type InnerProductParameter
    num_output::UInt32
    bias_term::Bool
    weight_filler::FillerParameter
    bias_filler::FillerParameter
    axis::Int32
    transpose::Bool
    InnerProductParameter(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #type InnerProductParameter
const __val_InnerProductParameter = @compat Dict(:bias_term => true, :axis => 1, :transpose => false)
meta(t::Type{InnerProductParameter}) = meta(t, ProtoBuf.DEF_REQ, ProtoBuf.DEF_FNUM, __val_InnerProductParameter, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES)
hash(v::InnerProductParameter) = ProtoBuf.protohash(v)
isequal(v1::InnerProductParameter, v2::InnerProductParameter) = ProtoBuf.protoisequal(v1, v2)
==(v1::InnerProductParameter, v2::InnerProductParameter) = ProtoBuf.protoeq(v1, v2)

type InputParameter
    shape::Array{BlobShape,1}
    InputParameter(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #type InputParameter
hash(v::InputParameter) = ProtoBuf.protohash(v)
isequal(v1::InputParameter, v2::InputParameter) = ProtoBuf.protoisequal(v1, v2)
==(v1::InputParameter, v2::InputParameter) = ProtoBuf.protoeq(v1, v2)

type LogParameter
    base::Float32
    scale::Float32
    shift::Float32
    LogParameter(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #type LogParameter
const __val_LogParameter = @compat Dict(:base => -1, :scale => 1, :shift => 0)
meta(t::Type{LogParameter}) = meta(t, ProtoBuf.DEF_REQ, ProtoBuf.DEF_FNUM, __val_LogParameter, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES)
hash(v::LogParameter) = ProtoBuf.protohash(v)
isequal(v1::LogParameter, v2::LogParameter) = ProtoBuf.protoisequal(v1, v2)
==(v1::LogParameter, v2::LogParameter) = ProtoBuf.protoeq(v1, v2)

type __enum_LRNParameter_NormRegion <: ProtoEnum
    ACROSS_CHANNELS::Int32
    WITHIN_CHANNEL::Int32
    __enum_LRNParameter_NormRegion() = new(0,1)
end #type __enum_LRNParameter_NormRegion
const LRNParameter_NormRegion = __enum_LRNParameter_NormRegion()

type __enum_LRNParameter_Engine <: ProtoEnum
    DEFAULT::Int32
    CAFFE::Int32
    CUDNN::Int32
    __enum_LRNParameter_Engine() = new(0,1,2)
end #type __enum_LRNParameter_Engine
const LRNParameter_Engine = __enum_LRNParameter_Engine()

type LRNParameter
    local_size::UInt32
    alpha::Float32
    beta::Float32
    norm_region::Int32
    k::Float32
    engine::Int32
    LRNParameter(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #type LRNParameter
const __val_LRNParameter = @compat Dict(:local_size => 5, :alpha => 1, :beta => 0.75, :norm_region => LRNParameter_NormRegion.ACROSS_CHANNELS, :k => 1, :engine => LRNParameter_Engine.DEFAULT)
meta(t::Type{LRNParameter}) = meta(t, ProtoBuf.DEF_REQ, ProtoBuf.DEF_FNUM, __val_LRNParameter, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES)
hash(v::LRNParameter) = ProtoBuf.protohash(v)
isequal(v1::LRNParameter, v2::LRNParameter) = ProtoBuf.protoisequal(v1, v2)
==(v1::LRNParameter, v2::LRNParameter) = ProtoBuf.protoeq(v1, v2)

type MemoryDataParameter
    batch_size::UInt32
    channels::UInt32
    height::UInt32
    width::UInt32
    MemoryDataParameter(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #type MemoryDataParameter
hash(v::MemoryDataParameter) = ProtoBuf.protohash(v)
isequal(v1::MemoryDataParameter, v2::MemoryDataParameter) = ProtoBuf.protoisequal(v1, v2)
==(v1::MemoryDataParameter, v2::MemoryDataParameter) = ProtoBuf.protoeq(v1, v2)

type MVNParameter
    normalize_variance::Bool
    across_channels::Bool
    eps::Float32
    MVNParameter(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #type MVNParameter
const __val_MVNParameter = @compat Dict(:normalize_variance => true, :across_channels => false, :eps => 1e-09)
meta(t::Type{MVNParameter}) = meta(t, ProtoBuf.DEF_REQ, ProtoBuf.DEF_FNUM, __val_MVNParameter, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES)
hash(v::MVNParameter) = ProtoBuf.protohash(v)
isequal(v1::MVNParameter, v2::MVNParameter) = ProtoBuf.protoisequal(v1, v2)
==(v1::MVNParameter, v2::MVNParameter) = ProtoBuf.protoeq(v1, v2)

type __enum_PoolingParameter_PoolMethod <: ProtoEnum
    MAX::Int32
    AVE::Int32
    STOCHASTIC::Int32
    __enum_PoolingParameter_PoolMethod() = new(0,1,2)
end #type __enum_PoolingParameter_PoolMethod
const PoolingParameter_PoolMethod = __enum_PoolingParameter_PoolMethod()

type __enum_PoolingParameter_Engine <: ProtoEnum
    DEFAULT::Int32
    CAFFE::Int32
    CUDNN::Int32
    __enum_PoolingParameter_Engine() = new(0,1,2)
end #type __enum_PoolingParameter_Engine
const PoolingParameter_Engine = __enum_PoolingParameter_Engine()

type PoolingParameter
    pool::Int32
    pad::UInt32
    pad_h::UInt32
    pad_w::UInt32
    kernel_size::UInt32
    kernel_h::UInt32
    kernel_w::UInt32
    stride::UInt32
    stride_h::UInt32
    stride_w::UInt32
    engine::Int32
    global_pooling::Bool
    PoolingParameter(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #type PoolingParameter
const __val_PoolingParameter = @compat Dict(:pool => PoolingParameter_PoolMethod.MAX, :pad => 0, :pad_h => 0, :pad_w => 0, :stride => 1, :engine => PoolingParameter_Engine.DEFAULT, :global_pooling => false)
const __fnum_PoolingParameter = Int[1,4,9,10,2,5,6,3,7,8,11,12]
meta(t::Type{PoolingParameter}) = meta(t, ProtoBuf.DEF_REQ, __fnum_PoolingParameter, __val_PoolingParameter, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES)
hash(v::PoolingParameter) = ProtoBuf.protohash(v)
isequal(v1::PoolingParameter, v2::PoolingParameter) = ProtoBuf.protoisequal(v1, v2)
==(v1::PoolingParameter, v2::PoolingParameter) = ProtoBuf.protoeq(v1, v2)

type PowerParameter
    power::Float32
    scale::Float32
    shift::Float32
    PowerParameter(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #type PowerParameter
const __val_PowerParameter = @compat Dict(:power => 1, :scale => 1, :shift => 0)
meta(t::Type{PowerParameter}) = meta(t, ProtoBuf.DEF_REQ, ProtoBuf.DEF_FNUM, __val_PowerParameter, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES)
hash(v::PowerParameter) = ProtoBuf.protohash(v)
isequal(v1::PowerParameter, v2::PowerParameter) = ProtoBuf.protoisequal(v1, v2)
==(v1::PowerParameter, v2::PowerParameter) = ProtoBuf.protoeq(v1, v2)

type PythonParameter
    _module::AbstractString
    layer::AbstractString
    param_str::AbstractString
    share_in_parallel::Bool
    PythonParameter(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #type PythonParameter
const __val_PythonParameter = @compat Dict(:share_in_parallel => false)
meta(t::Type{PythonParameter}) = meta(t, ProtoBuf.DEF_REQ, ProtoBuf.DEF_FNUM, __val_PythonParameter, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES)
hash(v::PythonParameter) = ProtoBuf.protohash(v)
isequal(v1::PythonParameter, v2::PythonParameter) = ProtoBuf.protoisequal(v1, v2)
==(v1::PythonParameter, v2::PythonParameter) = ProtoBuf.protoeq(v1, v2)

type __enum_ReductionParameter_ReductionOp <: ProtoEnum
    SUM::Int32
    ASUM::Int32
    SUMSQ::Int32
    MEAN::Int32
    __enum_ReductionParameter_ReductionOp() = new(1,2,3,4)
end #type __enum_ReductionParameter_ReductionOp
const ReductionParameter_ReductionOp = __enum_ReductionParameter_ReductionOp()

type ReductionParameter
    operation::Int32
    axis::Int32
    coeff::Float32
    ReductionParameter(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #type ReductionParameter
const __val_ReductionParameter = @compat Dict(:operation => ReductionParameter_ReductionOp.SUM, :axis => 0, :coeff => 1)
meta(t::Type{ReductionParameter}) = meta(t, ProtoBuf.DEF_REQ, ProtoBuf.DEF_FNUM, __val_ReductionParameter, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES)
hash(v::ReductionParameter) = ProtoBuf.protohash(v)
isequal(v1::ReductionParameter, v2::ReductionParameter) = ProtoBuf.protoisequal(v1, v2)
==(v1::ReductionParameter, v2::ReductionParameter) = ProtoBuf.protoeq(v1, v2)

type __enum_ReLUParameter_Engine <: ProtoEnum
    DEFAULT::Int32
    CAFFE::Int32
    CUDNN::Int32
    __enum_ReLUParameter_Engine() = new(0,1,2)
end #type __enum_ReLUParameter_Engine
const ReLUParameter_Engine = __enum_ReLUParameter_Engine()

type ReLUParameter
    negative_slope::Float32
    engine::Int32
    ReLUParameter(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #type ReLUParameter
const __val_ReLUParameter = @compat Dict(:negative_slope => 0, :engine => ReLUParameter_Engine.DEFAULT)
meta(t::Type{ReLUParameter}) = meta(t, ProtoBuf.DEF_REQ, ProtoBuf.DEF_FNUM, __val_ReLUParameter, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES)
hash(v::ReLUParameter) = ProtoBuf.protohash(v)
isequal(v1::ReLUParameter, v2::ReLUParameter) = ProtoBuf.protoisequal(v1, v2)
==(v1::ReLUParameter, v2::ReLUParameter) = ProtoBuf.protoeq(v1, v2)

type ReshapeParameter
    shape::BlobShape
    axis::Int32
    num_axes::Int32
    ReshapeParameter(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #type ReshapeParameter
const __val_ReshapeParameter = @compat Dict(:axis => 0, :num_axes => -1)
meta(t::Type{ReshapeParameter}) = meta(t, ProtoBuf.DEF_REQ, ProtoBuf.DEF_FNUM, __val_ReshapeParameter, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES)
hash(v::ReshapeParameter) = ProtoBuf.protohash(v)
isequal(v1::ReshapeParameter, v2::ReshapeParameter) = ProtoBuf.protoisequal(v1, v2)
==(v1::ReshapeParameter, v2::ReshapeParameter) = ProtoBuf.protoeq(v1, v2)

type ScaleParameter
    axis::Int32
    num_axes::Int32
    filler::FillerParameter
    bias_term::Bool
    bias_filler::FillerParameter
    ScaleParameter(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #type ScaleParameter
const __val_ScaleParameter = @compat Dict(:axis => 1, :num_axes => 1, :bias_term => false)
meta(t::Type{ScaleParameter}) = meta(t, ProtoBuf.DEF_REQ, ProtoBuf.DEF_FNUM, __val_ScaleParameter, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES)
hash(v::ScaleParameter) = ProtoBuf.protohash(v)
isequal(v1::ScaleParameter, v2::ScaleParameter) = ProtoBuf.protoisequal(v1, v2)
==(v1::ScaleParameter, v2::ScaleParameter) = ProtoBuf.protoeq(v1, v2)

type __enum_SigmoidParameter_Engine <: ProtoEnum
    DEFAULT::Int32
    CAFFE::Int32
    CUDNN::Int32
    __enum_SigmoidParameter_Engine() = new(0,1,2)
end #type __enum_SigmoidParameter_Engine
const SigmoidParameter_Engine = __enum_SigmoidParameter_Engine()

type SigmoidParameter
    engine::Int32
    SigmoidParameter(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #type SigmoidParameter
const __val_SigmoidParameter = @compat Dict(:engine => SigmoidParameter_Engine.DEFAULT)
meta(t::Type{SigmoidParameter}) = meta(t, ProtoBuf.DEF_REQ, ProtoBuf.DEF_FNUM, __val_SigmoidParameter, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES)
hash(v::SigmoidParameter) = ProtoBuf.protohash(v)
isequal(v1::SigmoidParameter, v2::SigmoidParameter) = ProtoBuf.protoisequal(v1, v2)
==(v1::SigmoidParameter, v2::SigmoidParameter) = ProtoBuf.protoeq(v1, v2)

type SliceParameter
    axis::Int32
    slice_point::Array{UInt32,1}
    slice_dim::UInt32
    SliceParameter(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #type SliceParameter
const __val_SliceParameter = @compat Dict(:axis => 1, :slice_dim => 1)
const __fnum_SliceParameter = Int[3,2,1]
meta(t::Type{SliceParameter}) = meta(t, ProtoBuf.DEF_REQ, __fnum_SliceParameter, __val_SliceParameter, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES)
hash(v::SliceParameter) = ProtoBuf.protohash(v)
isequal(v1::SliceParameter, v2::SliceParameter) = ProtoBuf.protoisequal(v1, v2)
==(v1::SliceParameter, v2::SliceParameter) = ProtoBuf.protoeq(v1, v2)

type __enum_SoftmaxParameter_Engine <: ProtoEnum
    DEFAULT::Int32
    CAFFE::Int32
    CUDNN::Int32
    __enum_SoftmaxParameter_Engine() = new(0,1,2)
end #type __enum_SoftmaxParameter_Engine
const SoftmaxParameter_Engine = __enum_SoftmaxParameter_Engine()

type SoftmaxParameter
    engine::Int32
    axis::Int32
    SoftmaxParameter(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #type SoftmaxParameter
const __val_SoftmaxParameter = @compat Dict(:engine => SoftmaxParameter_Engine.DEFAULT, :axis => 1)
meta(t::Type{SoftmaxParameter}) = meta(t, ProtoBuf.DEF_REQ, ProtoBuf.DEF_FNUM, __val_SoftmaxParameter, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES)
hash(v::SoftmaxParameter) = ProtoBuf.protohash(v)
isequal(v1::SoftmaxParameter, v2::SoftmaxParameter) = ProtoBuf.protoisequal(v1, v2)
==(v1::SoftmaxParameter, v2::SoftmaxParameter) = ProtoBuf.protoeq(v1, v2)

type __enum_TanHParameter_Engine <: ProtoEnum
    DEFAULT::Int32
    CAFFE::Int32
    CUDNN::Int32
    __enum_TanHParameter_Engine() = new(0,1,2)
end #type __enum_TanHParameter_Engine
const TanHParameter_Engine = __enum_TanHParameter_Engine()

type TanHParameter
    engine::Int32
    TanHParameter(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #type TanHParameter
const __val_TanHParameter = @compat Dict(:engine => TanHParameter_Engine.DEFAULT)
meta(t::Type{TanHParameter}) = meta(t, ProtoBuf.DEF_REQ, ProtoBuf.DEF_FNUM, __val_TanHParameter, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES)
hash(v::TanHParameter) = ProtoBuf.protohash(v)
isequal(v1::TanHParameter, v2::TanHParameter) = ProtoBuf.protoisequal(v1, v2)
==(v1::TanHParameter, v2::TanHParameter) = ProtoBuf.protoeq(v1, v2)

type TileParameter
    axis::Int32
    tiles::Int32
    TileParameter(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #type TileParameter
const __val_TileParameter = @compat Dict(:axis => 1)
meta(t::Type{TileParameter}) = meta(t, ProtoBuf.DEF_REQ, ProtoBuf.DEF_FNUM, __val_TileParameter, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES)
hash(v::TileParameter) = ProtoBuf.protohash(v)
isequal(v1::TileParameter, v2::TileParameter) = ProtoBuf.protoisequal(v1, v2)
==(v1::TileParameter, v2::TileParameter) = ProtoBuf.protoeq(v1, v2)

type ThresholdParameter
    threshold::Float32
    ThresholdParameter(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #type ThresholdParameter
const __val_ThresholdParameter = @compat Dict(:threshold => 0)
meta(t::Type{ThresholdParameter}) = meta(t, ProtoBuf.DEF_REQ, ProtoBuf.DEF_FNUM, __val_ThresholdParameter, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES)
hash(v::ThresholdParameter) = ProtoBuf.protohash(v)
isequal(v1::ThresholdParameter, v2::ThresholdParameter) = ProtoBuf.protoisequal(v1, v2)
==(v1::ThresholdParameter, v2::ThresholdParameter) = ProtoBuf.protoeq(v1, v2)

type WindowDataParameter
    source::AbstractString
    scale::Float32
    mean_file::AbstractString
    batch_size::UInt32
    crop_size::UInt32
    mirror::Bool
    fg_threshold::Float32
    bg_threshold::Float32
    fg_fraction::Float32
    context_pad::UInt32
    crop_mode::AbstractString
    cache_images::Bool
    root_folder::AbstractString
    WindowDataParameter(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #type WindowDataParameter
const __val_WindowDataParameter = @compat Dict(:scale => 1, :crop_size => 0, :mirror => false, :fg_threshold => 0.5, :bg_threshold => 0.5, :fg_fraction => 0.25, :context_pad => 0, :crop_mode => "warp", :cache_images => false)
meta(t::Type{WindowDataParameter}) = meta(t, ProtoBuf.DEF_REQ, ProtoBuf.DEF_FNUM, __val_WindowDataParameter, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES)
hash(v::WindowDataParameter) = ProtoBuf.protohash(v)
isequal(v1::WindowDataParameter, v2::WindowDataParameter) = ProtoBuf.protoisequal(v1, v2)
==(v1::WindowDataParameter, v2::WindowDataParameter) = ProtoBuf.protoeq(v1, v2)

type __enum_SPPParameter_PoolMethod <: ProtoEnum
    MAX::Int32
    AVE::Int32
    STOCHASTIC::Int32
    __enum_SPPParameter_PoolMethod() = new(0,1,2)
end #type __enum_SPPParameter_PoolMethod
const SPPParameter_PoolMethod = __enum_SPPParameter_PoolMethod()

type __enum_SPPParameter_Engine <: ProtoEnum
    DEFAULT::Int32
    CAFFE::Int32
    CUDNN::Int32
    __enum_SPPParameter_Engine() = new(0,1,2)
end #type __enum_SPPParameter_Engine
const SPPParameter_Engine = __enum_SPPParameter_Engine()

type SPPParameter
    pyramid_height::UInt32
    pool::Int32
    engine::Int32
    SPPParameter(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #type SPPParameter
const __val_SPPParameter = @compat Dict(:pool => SPPParameter_PoolMethod.MAX, :engine => SPPParameter_Engine.DEFAULT)
const __fnum_SPPParameter = Int[1,2,6]
meta(t::Type{SPPParameter}) = meta(t, ProtoBuf.DEF_REQ, __fnum_SPPParameter, __val_SPPParameter, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES)
hash(v::SPPParameter) = ProtoBuf.protohash(v)
isequal(v1::SPPParameter, v2::SPPParameter) = ProtoBuf.protoisequal(v1, v2)
==(v1::SPPParameter, v2::SPPParameter) = ProtoBuf.protoeq(v1, v2)

type __enum_V0LayerParameter_PoolMethod <: ProtoEnum
    MAX::Int32
    AVE::Int32
    STOCHASTIC::Int32
    __enum_V0LayerParameter_PoolMethod() = new(0,1,2)
end #type __enum_V0LayerParameter_PoolMethod
const V0LayerParameter_PoolMethod = __enum_V0LayerParameter_PoolMethod()

type V0LayerParameter
    name::AbstractString
    _type::AbstractString
    num_output::UInt32
    biasterm::Bool
    weight_filler::FillerParameter
    bias_filler::FillerParameter
    pad::UInt32
    kernelsize::UInt32
    group::UInt32
    stride::UInt32
    pool::Int32
    dropout_ratio::Float32
    local_size::UInt32
    alpha::Float32
    beta::Float32
    k::Float32
    source::AbstractString
    scale::Float32
    meanfile::AbstractString
    batchsize::UInt32
    cropsize::UInt32
    mirror::Bool
    blobs::Array{BlobProto,1}
    blobs_lr::Array{Float32,1}
    weight_decay::Array{Float32,1}
    rand_skip::UInt32
    det_fg_threshold::Float32
    det_bg_threshold::Float32
    det_fg_fraction::Float32
    det_context_pad::UInt32
    det_crop_mode::AbstractString
    new_num::Int32
    new_channels::Int32
    new_height::Int32
    new_width::Int32
    shuffle_images::Bool
    concat_dim::UInt32
    hdf5_output_param::HDF5OutputParameter
    V0LayerParameter(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #type V0LayerParameter
const __val_V0LayerParameter = @compat Dict(:biasterm => true, :pad => 0, :group => 1, :stride => 1, :pool => V0LayerParameter_PoolMethod.MAX, :dropout_ratio => 0.5, :local_size => 5, :alpha => 1, :beta => 0.75, :k => 1, :scale => 1, :cropsize => 0, :mirror => false, :rand_skip => 0, :det_fg_threshold => 0.5, :det_bg_threshold => 0.5, :det_fg_fraction => 0.25, :det_context_pad => 0, :det_crop_mode => "warp", :new_num => 0, :new_channels => 0, :new_height => 0, :new_width => 0, :shuffle_images => false, :concat_dim => 1)
const __fnum_V0LayerParameter = Int[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,22,16,17,18,19,20,21,50,51,52,53,54,55,56,58,59,60,61,62,63,64,65,1001]
meta(t::Type{V0LayerParameter}) = meta(t, ProtoBuf.DEF_REQ, __fnum_V0LayerParameter, __val_V0LayerParameter, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES)
hash(v::V0LayerParameter) = ProtoBuf.protohash(v)
isequal(v1::V0LayerParameter, v2::V0LayerParameter) = ProtoBuf.protoisequal(v1, v2)
==(v1::V0LayerParameter, v2::V0LayerParameter) = ProtoBuf.protoeq(v1, v2)

type __enum_V1LayerParameter_LayerType <: ProtoEnum
    NONE::Int32
    ABSVAL::Int32
    ACCURACY::Int32
    ARGMAX::Int32
    BNLL::Int32
    CONCAT::Int32
    CONTRASTIVE_LOSS::Int32
    CONVOLUTION::Int32
    DATA::Int32
    DECONVOLUTION::Int32
    DROPOUT::Int32
    DUMMY_DATA::Int32
    EUCLIDEAN_LOSS::Int32
    ELTWISE::Int32
    EXP::Int32
    FLATTEN::Int32
    HDF5_DATA::Int32
    HDF5_OUTPUT::Int32
    HINGE_LOSS::Int32
    IM2COL::Int32
    IMAGE_DATA::Int32
    INFOGAIN_LOSS::Int32
    INNER_PRODUCT::Int32
    LRN::Int32
    MEMORY_DATA::Int32
    MULTINOMIAL_LOGISTIC_LOSS::Int32
    MVN::Int32
    POOLING::Int32
    POWER::Int32
    RELU::Int32
    SIGMOID::Int32
    SIGMOID_CROSS_ENTROPY_LOSS::Int32
    SILENCE::Int32
    SOFTMAX::Int32
    SOFTMAX_LOSS::Int32
    SPLIT::Int32
    SLICE::Int32
    TANH::Int32
    WINDOW_DATA::Int32
    THRESHOLD::Int32
    __enum_V1LayerParameter_LayerType() = new(0,35,1,30,2,3,37,4,5,39,6,32,7,25,38,8,9,10,28,11,12,13,14,15,29,16,34,17,26,18,19,27,36,20,21,22,33,23,24,31)
end #type __enum_V1LayerParameter_LayerType
const V1LayerParameter_LayerType = __enum_V1LayerParameter_LayerType()

type __enum_V1LayerParameter_DimCheckMode <: ProtoEnum
    STRICT::Int32
    PERMISSIVE::Int32
    __enum_V1LayerParameter_DimCheckMode() = new(0,1)
end #type __enum_V1LayerParameter_DimCheckMode
const V1LayerParameter_DimCheckMode = __enum_V1LayerParameter_DimCheckMode()

type V1LayerParameter
    bottom::Array{AbstractString,1}
    top::Array{AbstractString,1}
    name::AbstractString
    include::Array{NetStateRule,1}
    exclude::Array{NetStateRule,1}
    _type::Int32
    blobs::Array{BlobProto,1}
    param::Array{AbstractString,1}
    blob_share_mode::Array{Int32,1}
    blobs_lr::Array{Float32,1}
    weight_decay::Array{Float32,1}
    loss_weight::Array{Float32,1}
    accuracy_param::AccuracyParameter
    argmax_param::ArgMaxParameter
    concat_param::ConcatParameter
    contrastive_loss_param::ContrastiveLossParameter
    convolution_param::ConvolutionParameter
    data_param::DataParameter
    dropout_param::DropoutParameter
    dummy_data_param::DummyDataParameter
    eltwise_param::EltwiseParameter
    exp_param::ExpParameter
    hdf5_data_param::HDF5DataParameter
    hdf5_output_param::HDF5OutputParameter
    hinge_loss_param::HingeLossParameter
    image_data_param::ImageDataParameter
    infogain_loss_param::InfogainLossParameter
    inner_product_param::InnerProductParameter
    lrn_param::LRNParameter
    memory_data_param::MemoryDataParameter
    mvn_param::MVNParameter
    pooling_param::PoolingParameter
    power_param::PowerParameter
    relu_param::ReLUParameter
    sigmoid_param::SigmoidParameter
    softmax_param::SoftmaxParameter
    slice_param::SliceParameter
    tanh_param::TanHParameter
    threshold_param::ThresholdParameter
    window_data_param::WindowDataParameter
    transform_param::TransformationParameter
    loss_param::LossParameter
    layer::V0LayerParameter
    V1LayerParameter(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #type V1LayerParameter
const __fnum_V1LayerParameter = Int[2,3,4,32,33,5,6,1001,1002,7,8,35,27,23,9,40,10,11,12,26,24,41,13,14,29,15,16,17,18,22,34,19,21,30,38,39,31,37,25,20,36,42,1]
meta(t::Type{V1LayerParameter}) = meta(t, ProtoBuf.DEF_REQ, __fnum_V1LayerParameter, ProtoBuf.DEF_VAL, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES)
hash(v::V1LayerParameter) = ProtoBuf.protohash(v)
isequal(v1::V1LayerParameter, v2::V1LayerParameter) = ProtoBuf.protoisequal(v1, v2)
==(v1::V1LayerParameter, v2::V1LayerParameter) = ProtoBuf.protoeq(v1, v2)

type PReLUParameter
    filler::FillerParameter
    channel_shared::Bool
    PReLUParameter(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #type PReLUParameter
const __val_PReLUParameter = @compat Dict(:channel_shared => false)
meta(t::Type{PReLUParameter}) = meta(t, ProtoBuf.DEF_REQ, ProtoBuf.DEF_FNUM, __val_PReLUParameter, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES)
hash(v::PReLUParameter) = ProtoBuf.protohash(v)
isequal(v1::PReLUParameter, v2::PReLUParameter) = ProtoBuf.protoisequal(v1, v2)
==(v1::PReLUParameter, v2::PReLUParameter) = ProtoBuf.protoeq(v1, v2)

type LayerParameter
    name::AbstractString
    _type::AbstractString
    bottom::Array{AbstractString,1}
    top::Array{AbstractString,1}
    phase::Int32
    loss_weight::Array{Float32,1}
    param::Array{ParamSpec,1}
    blobs::Array{BlobProto,1}
    propagate_down::Array{Bool,1}
    include::Array{NetStateRule,1}
    exclude::Array{NetStateRule,1}
    transform_param::TransformationParameter
    loss_param::LossParameter
    accuracy_param::AccuracyParameter
    argmax_param::ArgMaxParameter
    batch_norm_param::BatchNormParameter
    bias_param::BiasParameter
    concat_param::ConcatParameter
    contrastive_loss_param::ContrastiveLossParameter
    convolution_param::ConvolutionParameter
    crop_param::CropParameter
    data_param::DataParameter
    dropout_param::DropoutParameter
    dummy_data_param::DummyDataParameter
    eltwise_param::EltwiseParameter
    elu_param::ELUParameter
    embed_param::EmbedParameter
    exp_param::ExpParameter
    flatten_param::FlattenParameter
    hdf5_data_param::HDF5DataParameter
    hdf5_output_param::HDF5OutputParameter
    hinge_loss_param::HingeLossParameter
    image_data_param::ImageDataParameter
    infogain_loss_param::InfogainLossParameter
    inner_product_param::InnerProductParameter
    input_param::InputParameter
    log_param::LogParameter
    lrn_param::LRNParameter
    memory_data_param::MemoryDataParameter
    mvn_param::MVNParameter
    pooling_param::PoolingParameter
    power_param::PowerParameter
    prelu_param::PReLUParameter
    python_param::PythonParameter
    reduction_param::ReductionParameter
    relu_param::ReLUParameter
    reshape_param::ReshapeParameter
    scale_param::ScaleParameter
    sigmoid_param::SigmoidParameter
    softmax_param::SoftmaxParameter
    spp_param::SPPParameter
    slice_param::SliceParameter
    tanh_param::TanHParameter
    threshold_param::ThresholdParameter
    tile_param::TileParameter
    window_data_param::WindowDataParameter
    LayerParameter(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #type LayerParameter
const __fnum_LayerParameter = Int[1,2,3,4,10,5,6,7,11,8,9,100,101,102,103,139,141,104,105,106,144,107,108,109,110,140,137,111,135,112,113,114,115,116,117,143,134,118,119,120,121,122,131,130,136,123,133,142,124,125,132,126,127,128,138,129]
meta(t::Type{LayerParameter}) = meta(t, ProtoBuf.DEF_REQ, __fnum_LayerParameter, ProtoBuf.DEF_VAL, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES)
hash(v::LayerParameter) = ProtoBuf.protohash(v)
isequal(v1::LayerParameter, v2::LayerParameter) = ProtoBuf.protoisequal(v1, v2)
==(v1::LayerParameter, v2::LayerParameter) = ProtoBuf.protoeq(v1, v2)

type NetParameter
    name::AbstractString
    input::Array{AbstractString,1}
    input_shape::Array{BlobShape,1}
    input_dim::Array{Int32,1}
    force_backward::Bool
    state::NetState
    debug_info::Bool
    layer::Array{LayerParameter,1}
    layers::Array{V1LayerParameter,1}
    NetParameter(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #type NetParameter
const __val_NetParameter = @compat Dict(:force_backward => false, :debug_info => false)
const __fnum_NetParameter = Int[1,3,8,4,5,6,7,100,2]
meta(t::Type{NetParameter}) = meta(t, ProtoBuf.DEF_REQ, __fnum_NetParameter, __val_NetParameter, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES)
hash(v::NetParameter) = ProtoBuf.protohash(v)
isequal(v1::NetParameter, v2::NetParameter) = ProtoBuf.protoisequal(v1, v2)
==(v1::NetParameter, v2::NetParameter) = ProtoBuf.protoeq(v1, v2)

type __enum_SolverParameter_SnapshotFormat <: ProtoEnum
    HDF5::Int32
    BINARYPROTO::Int32
    __enum_SolverParameter_SnapshotFormat() = new(0,1)
end #type __enum_SolverParameter_SnapshotFormat
const SolverParameter_SnapshotFormat = __enum_SolverParameter_SnapshotFormat()

type __enum_SolverParameter_SolverMode <: ProtoEnum
    CPU::Int32
    GPU::Int32
    __enum_SolverParameter_SolverMode() = new(0,1)
end #type __enum_SolverParameter_SolverMode
const SolverParameter_SolverMode = __enum_SolverParameter_SolverMode()

type __enum_SolverParameter_SolverType <: ProtoEnum
    SGD::Int32
    NESTEROV::Int32
    ADAGRAD::Int32
    RMSPROP::Int32
    ADADELTA::Int32
    ADAM::Int32
    __enum_SolverParameter_SolverType() = new(0,1,2,3,4,5)
end #type __enum_SolverParameter_SolverType
const SolverParameter_SolverType = __enum_SolverParameter_SolverType()

type SolverParameter
    net::AbstractString
    net_param::NetParameter
    train_net::AbstractString
    test_net::Array{AbstractString,1}
    train_net_param::NetParameter
    test_net_param::Array{NetParameter,1}
    train_state::NetState
    test_state::Array{NetState,1}
    test_iter::Array{Int32,1}
    test_interval::Int32
    test_compute_loss::Bool
    test_initialization::Bool
    base_lr::Float32
    display::Int32
    average_loss::Int32
    max_iter::Int32
    iter_size::Int32
    lr_policy::AbstractString
    gamma::Float32
    power::Float32
    momentum::Float32
    weight_decay::Float32
    regularization_type::AbstractString
    stepsize::Int32
    stepvalue::Array{Int32,1}
    clip_gradients::Float32
    snapshot::Int32
    snapshot_prefix::AbstractString
    snapshot_diff::Bool
    snapshot_format::Int32
    solver_mode::Int32
    device_id::Int32
    random_seed::Int64
    _type::AbstractString
    delta::Float32
    momentum2::Float32
    rms_decay::Float32
    debug_info::Bool
    snapshot_after_train::Bool
    solver_type::Int32
    SolverParameter(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #type SolverParameter
const __val_SolverParameter = @compat Dict(:test_interval => 0, :test_compute_loss => false, :test_initialization => true, :average_loss => 1, :iter_size => 1, :regularization_type => "L2", :clip_gradients => -1, :snapshot => 0, :snapshot_diff => false, :snapshot_format => SolverParameter_SnapshotFormat.BINARYPROTO, :solver_mode => SolverParameter_SolverMode.GPU, :device_id => 0, :random_seed => -1, :_type => "SGD", :delta => 1e-08, :momentum2 => 0.999, :debug_info => false, :snapshot_after_train => true, :solver_type => SolverParameter_SolverType.SGD)
const __fnum_SolverParameter = Int[24,25,1,2,21,22,26,27,3,4,19,32,5,6,33,7,36,8,9,10,11,12,29,13,34,35,14,15,16,37,17,18,20,40,31,39,38,23,28,30]
meta(t::Type{SolverParameter}) = meta(t, ProtoBuf.DEF_REQ, __fnum_SolverParameter, __val_SolverParameter, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES)
hash(v::SolverParameter) = ProtoBuf.protohash(v)
isequal(v1::SolverParameter, v2::SolverParameter) = ProtoBuf.protoisequal(v1, v2)
==(v1::SolverParameter, v2::SolverParameter) = ProtoBuf.protoeq(v1, v2)

export Phase, BlobShape, BlobProto, BlobProtoVector, Datum, FillerParameter_VarianceNorm, FillerParameter, NetParameter, SolverParameter_SnapshotFormat, SolverParameter_SolverMode, SolverParameter_SolverType, SolverParameter, SolverState, NetState, NetStateRule, ParamSpec_DimCheckMode, ParamSpec, LayerParameter, TransformationParameter, LossParameter_NormalizationMode, LossParameter, AccuracyParameter, ArgMaxParameter, ConcatParameter, BatchNormParameter, BiasParameter, ContrastiveLossParameter, ConvolutionParameter_Engine, ConvolutionParameter, CropParameter, DataParameter_DB, DataParameter, DropoutParameter, DummyDataParameter, EltwiseParameter_EltwiseOp, EltwiseParameter, ELUParameter, EmbedParameter, ExpParameter, FlattenParameter, HDF5DataParameter, HDF5OutputParameter, HingeLossParameter_Norm, HingeLossParameter, ImageDataParameter, InfogainLossParameter, InnerProductParameter, InputParameter, LogParameter, LRNParameter_NormRegion, LRNParameter_Engine, LRNParameter, MemoryDataParameter, MVNParameter, PoolingParameter_PoolMethod, PoolingParameter_Engine, PoolingParameter, PowerParameter, PythonParameter, ReductionParameter_ReductionOp, ReductionParameter, ReLUParameter_Engine, ReLUParameter, ReshapeParameter, ScaleParameter, SigmoidParameter_Engine, SigmoidParameter, SliceParameter, SoftmaxParameter_Engine, SoftmaxParameter, TanHParameter_Engine, TanHParameter, TileParameter, ThresholdParameter, WindowDataParameter, SPPParameter_PoolMethod, SPPParameter_Engine, SPPParameter, V1LayerParameter_LayerType, V1LayerParameter_DimCheckMode, V1LayerParameter, V0LayerParameter_PoolMethod, V0LayerParameter, PReLUParameter


text:
# Optimization of bin counts for histograms, heatmaps, hexbin plots, etc.
#
# I'm using the penalized maximum-likelihood method proposed in
#   Birge, L, and Rozenholc, Y. (2006) How many bins should be put in a regular
#   histogram?
#
# There has been quite a bit written on this problem, but there are a number of
# methods that all seem to give good results with little difference. Birge's
# method is simple (it's just AIC with an extra logarithmic term), has a decent
# theoretical justification, and is general enough to apply to multidimensional
# and non-regular bin selecetion problems. Though, the penalty they use was
# optimized for regular histograms, so may need to be tweaked.
#
# The Birge penalty is
#    penalty(D) = D - 1 + log(D)^2.5
# where D is the number of bins. The 2.5 constant was arrived at emperically by
# optimizing over samples from example density functions.
#

# Penalized log-likelihood function for a histogram with d regular bins.
#
# Args:
#   d: Number of bins in the histogram.
#   n: Number of sample (which should equal sum(bincounts[1:d])).
#   bincounts: An array giving the number occurrences in each bin.
#   binwidth: Width of each bin in the histogram.
#
# Returns:
#   Log-likelihood with Birge's penalty applied.
#
function bincount_pll(d::Int, n::Int, bincounts::Vector{Int}, binwidth::Float64)
    ll = 0
    for i in 1:d
        if bincounts[i] > 0
            ll += bincounts[i] * log(d * bincounts[i] / (n * binwidth))
        end
    end

    ll - (d - 1 + log(d)^2.5)
end

# Optimize the number of bins for a regular one dimensional histogram.
#
# Args:
#   xs: A sample.
#   d_min: Minimum number of bins to consider.
#   d_max: Maximum number of bins to consider.
#
# Returns:
#   A tuple of the form (d, bincounts, x_max), where d gives the optimal number of
#   bins, and bincounts is an array giving the number of occurances in each
#   bin, and x_max is the end point of the final bin.
#
function choose_bin_count_1d(xs::AbstractVector, d_min=1, d_max=150)
    n = length(xs)
    if n == 0
        return 1, Int[0], 0
    elseif n == 1
        return 1, Int[1], xs[1]
    end

    x_min, x_max = Gadfly.concrete_minimum(xs), Gadfly.concrete_maximum(xs)
    span = x_max - x_min

    bincounts = zeros(Int, d_max)

    d_best = d_min
    pll_best = -Inf

    # Brute force optimization: since the number of bins has to be reasonably
    # small to plot, this is pretty quick and very simple.
    for d in d_min:d_max
        binwidth = span / d
        bincounts[1:d] = 0

        for x in xs
            if !isconcrete(x)
                continue
            end
            bincounts[max(1, min(d, int(ceil((x - x_min) / binwidth))))] += 1
        end

        pll = bincount_pll(d, n, bincounts, binwidth)

        if pll > pll_best
            d_best = d
            pll_best = pll
        end
    end

    bincounts[1:d_best] = 0
    binwidth = span / d_best
    for x in xs
        if !isconcrete(x)
            continue
        end
        bincounts[max(1, min(d_best, int(ceil((x - x_min) / binwidth))))] += 1
    end

    return d_best, bincounts, x_max
end

# Choose a reasonable number of bins when the data is considered discrete, which
# this case means integers, or low-resolution real number measurements.
#
# This works similarly to choose_bin_count_1d, except restricts the binwidths to
# be a multiple of the smallest distance between two adjacent unique values.
# E.g. for integer data, this means bin width are integers as well. This usually
# leads to better results.
#
# Args:
#   xs: A sample.
#   xs_set: An of the unique values in xs in sorted order.
#   d_min: Minimum number of allowed bins.
#   d_max: Maximum number of allowed bins.
#
# Returns
#   A tuple of the form (d, bincounts, x_max), where d gives the optimal number of
#   bins, and bincounts is an array giving the number of occurances in each
#   bin, and x_max is the end point of the final bin.
#
function choose_bin_count_1d_discrete(xs::AbstractArray, xs_set::AbstractArray,
                                      d_min=1, d_max=150)
    n = length(xs_set)
    if n == 0
        return 1, Int[0], 0
    elseif n == 1
        return 1, Int[length(xs)], xs[1] + one(eltype(xs))
    end

    # minimum distance between two values
    mingap = zero(eltype(xs))
    for (i, j) in zip(1:length(xs_set)-1, 2:length(xs_set))
        a, b = xs[i], xs[j]
        gap = abs(a - b)
        if isconcrete(gap) && gap > zero(eltype(xs))
            if mingap == zero(eltype(xs))
                mingap = gap
            else
                mingap = min(gap, mingap)
            end
        end
    end

    x_min, x_max = Gadfly.concrete_minimum(xs), Gadfly.concrete_maximum(xs)
    span = x_max - x_min

    d_best = d_min
    pll_best = -Inf
    bincounts = zeros(Int, d_max)
    for d in d_min:d_max
        binwidth = span / d
        binwidth = ceil(binwidth / mingap) * mingap # round to a multiple of mingap

        # don't bother with binning that stretches past the end of the data
        if binwidth == mingap && x_min + binwidth * (d - 1) > x_max
            break
        end

        bincounts[1:d] = 0
        for x in xs
            if !isconcrete(x)
                continue
            end
            bincounts[max(1, min(d, int(ceil((x - x_min) / binwidth))))] += 1
        end

        pll = bincount_pll(d, n, bincounts, binwidth)

        if pll > pll_best
            d_best = d
            pll_best = pll
        end
    end

    d = d_best
    binwidth = ceil(span / d / mingap) * mingap
    x_max = x_min + binwidth * d
    bincounts[1:d_best] = 0
    for x in xs
        if !isconcrete(x)
            continue
        end
        bincounts[max(1, min(d_best, int(ceil((x - x_min) / binwidth))))] += 1
    end

    return d_best, bincounts, x_max
end

# Optimize the number of bins for regular two dimensional histograms.
#
# Args:
#   xs: Dimension one data.
#   ys: Dimension two data.
#
# Returns:
#   A tuple of the form (dx, dy, bincounts), where dx, dy gives the number of
#   bins in each respective dimension and bincounts is a dx by dy matrix giving
#   the count in each bin.
#
function choose_bin_count_2d(xs::AbstractVector, ys::AbstractVector,
                             xminbincount::Int, xmaxbincount::Int,
                             yminbincount::Int, ymaxbincount::Int)

    # For two demensions, I'm just going to optimize the marginal bin counts.
    # This might not be optimal, but its simple and fast.

    x_min, x_max = Gadfly.concrete_minimum(xs), Gadfly.concrete_maximum(xs)
    y_min, y_max = Gadfly.concrete_minimum(ys), Gadfly.concrete_maximum(ys)

    dx, _ = choose_bin_count_1d(xs, xminbincount, xmaxbincount)
    dy, _ = choose_bin_count_1d(ys, yminbincount, ymaxbincount)

    # bin widths
    wx = (x_max - x_min) / dx
    wy = (y_max - y_min) / dy

    bincounts = zeros(Int, (dy, dx))
    for (x, y) in zip(xs, ys)
        if !Gadfly.isconcrete(x) || !Gadfly.isconcrete(y)
            continue
        end

        i = max(1, min(dx, int(ceil((x - x_min) / wx))))
        j = max(1, min(dy, int(ceil((y - y_min) / wy))))
        bincounts[j, i] += 1
    end

    (dy, dx, bincounts)
end

# Optimize the number of bins for hexagonal 2d histograms.
#
# Args:
#   xs: Dimension one data.
#   ys: Dimension two data.
#
# Returns:
#   A tuple of the form (size, bincounts), where 'size' is the hexagon size and
#   bincounts is an arrays storing the count for each hexagon, using axial
#   coordinates.
#
function choose_hex_bin_count(xs::AbstractVector, ys::AbstractVector)
    # TODO: this should probably be a thing
end

ext: jl


text:
function plot3!(x::AV{<:Real}, y::AV{<:Real}, z::AV{<:Real};
                axes=nothing, overwrite=false, o...)
    # check dimensions
    if !(length(x) == length(y) == length(z))
        throw(DimensionMismatch("x,y and z data must have the same length."))
    end
    d = vcat(x,y,z)
    if any(isnan, d) || any(isinf, d)
        throw(ArgumentError("x,y and z cannot have NaNs or Inf values."))
    end
    axes = check_axes(axes; dims=3)
    if overwrite
        all(isempty, (axes.drawings, axes.objects)) || reset!(axes; parent=axes.parent)
    end

    # force axis limits, this is because GLE has a bug whereby it assumes everything is in the
    # [0,1]x[0,1]x[...] cube and scales thing badly if they're not so in order to scale things
    # correctly, we must know exactly what the axis limits are.
    xmin, xmax = extrema(x)
    ymin, ymax = extrema(y)
    zmin, zmax = extrema(z)
    δx = xmax-xmin
    δy = ymax-ymin
    δz = zmax-zmin
    xmin = xmin - 0.1δx
    xmax = xmax + 0.1δx
    ymin = ymin - 0.1δy
    ymax = ymax + 0.1δy
    zmin = zmin - 0.1δz
    zmax = zmax + 0.1δz
    axes.xaxis.min = rmin(axes.xaxis.min, xmin)
    axes.yaxis.min = rmin(axes.yaxis.min, ymin)
    axes.zaxis.min = rmin(axes.zaxis.min, zmin)
    axes.xaxis.max = rmax(axes.xaxis.max, xmax)
    axes.yaxis.max = rmax(axes.yaxis.max, ymax)
    axes.zaxis.max = rmax(axes.zaxis.max, zmax)

    # add the 3D scatter to the stack
    scatter3 = Scatter3D(data=zip(x,y,z))
    # default = simple line (possibly modified by setprops)
    scatter3.linestyle.lstyle = 1
    set_properties!(scatter3; defer_preview=true, o...)
    push!(axes.drawings, scatter3)
    return DrawingHandle(scatter3)
end

"""
    plot3(...)

Erase previous drawings and add a plot3. See also [`plot3!`](@ref).
"""
plot3(a...; o...) = plot3!(a...; overwrite=true, o...)

"""
    scatter3!(...)

Add a 3D scatter plot (no line joins the points). See also [`plot3!`](@ref).
"""
scatter3!(a...; o...) = plot3!(a...; ls="none", marker=".", o...)

"""
    scatter3(...)

Erase previous drawings and add a 3D scatter plot (no line joins the points). See also [`plot3`](@ref).
"""
scatter3(a...; o...)  = scatter3!(a...; overwrite=true, o...)


text:
# setup internal paths -
_PATH_TO_SRC = dirname(pathof(@__MODULE__))

# load external packages that we depend upon -
using Reexport
using DataFrames
using CSV
using Distributions
using Dates
using Statistics
using StatsPlots
using LinearAlgebra

# let's extend the sample method in distribution -
import Distributions.sample

# load my codes -
include(joinpath(_PATH_TO_SRC, "Types.jl"))
include(joinpath(_PATH_TO_SRC, "Base.jl"))
include(joinpath(_PATH_TO_SRC, "Compute.jl"))


text:
using  Flux
using Transformers.Basic

struct WordPositionEmbed
    word::Embed
    position::PositionEmbedding
end

Flux.@functor WordPositionEmbed
Flux.trainable(embed::WordPositionEmbed) = (embed.word, embed.position)

function (embed::WordPositionEmbed)(indices::AbstractArray{<:Number})
    word_embedding = embed.word(indices)
    embedding = word_embedding .+ embed.position(word_embedding)
    return embedding
end

function WordPositionEmbed(
    size::Int,
    vocab_size::Int,
    max_len::Int=1024;
    trainable::Bool=false,
    scale=inv(sqrt(size))
)::WordPositionEmbed
    return WordPositionEmbed(
        Embed(size, vocab_size, scale=scale),
        PositionEmbedding(size, max_len, trainable=trainable)
    )
end


text:
export
    PNGFrames,
    SVGFrames

PNGFrames(; fps::Int=24) = Reel.Frames(MIME("image/png"), fps=fps)
SVGFrames(; fps::Int=24) = Reel.Frames(MIME("image/svg"), fps=fps)


text:
include("../../src/datasets/dataset_reader.jl")

const dataset_test1_filename = "amostras.txt"
const dataset_test2_filename = "amostras_2T.txt"

function get_numerical_dataset_test1(path::String="")
    data = get_data(joinpath(path, "Teste_IM", dataset_test1_filename), dlm=" ", delete_first_line=false)

    conversion_pattern = [Float64, Float64]
    data = convert_values(data, conversion_pattern)
    separate_input_output(data,  output_columns=1)
end

function get_numerical_dataset_test2(path::String="")
    data = get_data(joinpath(path, "Teste_IM", dataset_test2_filename), dlm=" ", delete_first_line=false)

    conversion_pattern = [Float64, Float64, Float64]
    data = convert_values(data, conversion_pattern)
    separate_input_output(data,  output_columns=2)
end

max_stars_repo_name: Lucas-Muniz/MNEAT

max_issues_repo_name: Lucas-Muniz/MNEAT

max_forks_repo_name: Lucas-Muniz/MNEAT


text:
struct NormaliseDataContext{N,T <:AbstractMatrix} <: AbstractNormaliseDataContext
    transformations::NTuple{N,T}
end

function matrices(context::NormaliseDataContext)
    context.transformations
end

NormaliseDataContext(observations::AbstractObservations, method::AbstractNormalisationMethod) = NormaliseDataContext(method(observations))

function (method::AbstractNormalisationMethod)(observations::AbstractObservations)
    return method(observations)
end

function (method::IsotropicScalingTranslation)(observations::AbstractObservations)
    @unpack data = observations
    𝐓 = isotropic_scale_and_translate(data[1])
    return tuple(𝐓)
end

function (method::IsotropicScaling)(observations::AbstractObservations)
    @unpack data = observations
    𝐓 = isotropic_scale(data[1])
    return tuple(𝐓)
end

function (normalise_data::NormaliseDataContext)(observations::Observations)
    transformations = matrices(normalise_data)
    data = _normalise_data(observations, transformations)
    return Observations(data)
end

function (normalise_data::NormaliseDataContext)(observations::UncertainObservations)
    transformations = matrices(normalise_data)
    data = _normalise_data(observations, transformations)
    covariance_matrices = _normalise_covariance_matrices(observations, transformations)
    return UncertainObservations(data, covariance_matrices)
end

function _normalise_data(observations::AbstractObservations, transformations)
    @unpack data = observations
    𝐓₁ = transformations[1]
    ℳ = data[1]
    return tuple(transform_data(ℳ, 𝐓₁))
end

function  _normalise_covariance_matrices(observations::AbstractObservations, transformations)
    @unpack covariance_matrices = observations
    𝐓₁ = transformations[1]
    Λ = covariance_matrices[1]
    D = size(first(Λ),1)
    return tuple(transform_covariance(Λ, 𝐓₁, Val(D)))
end

function isotropic_scale_and_translate(ℳ::AbstractVector)
    if isempty(ℳ)
        throw(ArgumentError("Array cannot be empty."))
    end
    npts = length(ℳ)
    ndim = length(ℳ[1])
    𝐜 = centroid(ℳ)
    σ = root_mean_square(ℳ, 𝐜)
    σ⁻¹ = 1 / σ
    𝐓 = SMatrix{ndim+1,ndim+1,Float64, (ndim+1)^2}([σ⁻¹*Matrix{Float64}(I,ndim,ndim) -σ⁻¹*𝐜 ; zeros(1,ndim) 1.0])
end

function isotropic_scale(ℳ::AbstractVector)
    if isempty(ℳ)
        throw(ArgumentError("Array cannot be empty."))
    end
    npts = length(ℳ)
    ndim = length(ℳ[1])
    𝐜 = centroid(ℳ)
    σ = root_mean_square(ℳ, 𝐜)
    σ⁻¹ = 1 / σ
    𝐓 = SMatrix{ndim+1,ndim+1,Float64, (ndim+1)^2}([σ⁻¹*Matrix{Float64}(I,ndim,ndim) zeros(ndim) ; zeros(1,ndim) 1.0])
end

function centroid(positions::AbstractVector)
    x = zeros(eltype(positions))
    for pos ∈ positions
        x = x + pos
    end
    return x / length(positions)
end

function root_mean_square(ℳ::AbstractVector, 𝐜::AbstractVector)
    total = 0.0
    npts = length(ℳ)
    ndim = length(ℳ[1])
    for 𝐦 ∈ ℳ
         total  = total + ∑((𝐦-𝐜).^2)
    end
    σ = √( (1/(npts*ndim)) * total)
end

function transform_data(ℳ::AbstractVector, 𝐓::AbstractMatrix)
    𝒪 = transform_data!(copy(ℳ), 𝐓)
end

function transform_data!(ℳ::AbstractVector, 𝐓::AbstractMatrix)
    map!(ℳ , ℳ) do 𝐦
         hom⁻¹(𝐓 * hom(𝐦))
    end
     ℳ
end

function transform_data(ℳ::AbstractVector)
    𝒪, 𝐓 = transform_data!(copy(ℳ))
end

function transform_data!(ℳ::AbstractVector)
    𝐓 = transform_data(ℳ)
    map!(ℳ , ℳ) do 𝐦
         hom⁻¹(𝐓 * hom(𝐦))
    end
     ℳ, 𝐓
end

function transform_covariance(Λ::AbstractVector, 𝐓::AbstractMatrix, ndim::Val{2})
    Λ₂ = map(Λ) do 𝚲
       # Lift the covariance matrix so that it correspond to homeogenous coordinates.
       # This way the requisite transformation can be computed by multiply with a matrix 𝐓.
       𝚲₀ =  hcat(𝚲, SVector(0.0, 0.0))
       𝚲₁ = vcat(𝚲₀, transpose(SVector(0.0, 0.0, 0.0)))
       𝚲₂ =  (𝐓 * 𝚲₁ * 𝐓')
       𝚲′ = SMatrix{2,2,Float64,4}(𝚲₂[1], 𝚲₂[2], 𝚲₂[4], 𝚲₂[5])
    end
end

function (coordinate_transformation::NormaliseDataContext)(direction::FromNormalisedSpace, 𝛉′::AbstractVector)
    𝒯 = matrices(coordinate_transformation)
    𝐓 = 𝒯[1]
    𝐄 = Diagonal(SVector(1, 2^-1, 1, 2^-1, 2^-1, 1))
    # Permutation matrix for interchanging the 3rd and 4th entries of a length-6 vector.
    𝐏₃₄ = Diagonal(SVector(0,1,0)) ⊗ SMatrix{2,2,Float64}(0,1,1,0) + Diagonal(SVector(1,0,1)) ⊗ SMatrix{2,2,Float64}(1,0,0,1)
    # 9 x 6 duplication matrix
    𝐃₃ = [1 0 0 0 0 0;
          0 1 0 0 0 0;
          0 0 1 0 0 0;
          0 1 0 0 0 0;
          0 0 0 1 0 0;
          0 0 0 0 1 0;
          0 0 1 0 0 0;
          0 0 0 0 1 0;
          0 0 0 0 0 1]
    𝛉 = 𝐄 \ 𝐏₃₄ * pinv(𝐃₃) * kron(𝐓, 𝐓)' * 𝐃₃ * 𝐏₃₄ * 𝐄 * 𝛉′
    𝛉 = 𝛉 / norm(𝛉)
    return 𝛉
end

function (coordinate_transformation::NormaliseDataContext)(direction::ToNormalisedSpace, 𝛉::AbstractVector)
    𝒯 = matrices(coordinate_transformation)
    𝐓 = 𝒯[1]
    𝐄 = Diagonal(SVector(1, 2^-1, 1, 2^-1, 2^-1, 1))
    # Permutation matrix for interchanging the 3rd and 4th entries of a length-6 vector.
    𝐏₃₄ = Diagonal(SVector(0,1,0)) ⊗ SMatrix{2,2,Float64}(0,1,1,0) + Diagonal(SVector(1,0,1)) ⊗ SMatrix{2,2,Float64}(1,0,0,1)
    # 9 x 6 duplication matrix
    𝐃₃ = [1 0 0 0 0 0;
          0 1 0 0 0 0;
          0 0 1 0 0 0;
          0 1 0 0 0 0;
          0 0 0 1 0 0;
          0 0 0 0 1 0;
          0 0 1 0 0 0;
          0 0 0 0 1 0;
          0 0 0 0 0 1]
    𝛉′ = 𝐄 \ 𝐏₃₄ * pinv(𝐃₃) * inv(kron(𝐓, 𝐓))' * 𝐃₃ * 𝐏₃₄ * 𝐄 * 𝛉
    𝛉′ = 𝛉′ / norm(𝛉′)
    return 𝛉′
end


text:
## Time performance on VGG16

using BenchmarkTools
using Flux
using CUDA
using Zygote: pullback

function vgg16()
    Chain(
        Conv((3, 3), 3 => 64, relu, pad=(1, 1), stride=(1, 1)),
        BatchNorm(64),
        Conv((3, 3), 64 => 64, relu, pad=(1, 1), stride=(1, 1)),
        BatchNorm(64),
        MaxPool((2,2)),
        Conv((3, 3), 64 => 128, relu, pad=(1, 1), stride=(1, 1)),
        BatchNorm(128),
        Conv((3, 3), 128 => 128, relu, pad=(1, 1), stride=(1, 1)),
        BatchNorm(128),
        MaxPool((2,2)),
        Conv((3, 3), 128 => 256, relu, pad=(1, 1), stride=(1, 1)),
        BatchNorm(256),
        Conv((3, 3), 256 => 256, relu, pad=(1, 1), stride=(1, 1)),
        BatchNorm(256),
        Conv((3, 3), 256 => 256, relu, pad=(1, 1), stride=(1, 1)),
        BatchNorm(256),
        MaxPool((2,2)),
        Conv((3, 3), 256 => 512, relu, pad=(1, 1), stride=(1, 1)),
        BatchNorm(512),
        Conv((3, 3), 512 => 512, relu, pad=(1, 1), stride=(1, 1)),
        BatchNorm(512),
        Conv((3, 3), 512 => 512, relu, pad=(1, 1), stride=(1, 1)),
        BatchNorm(512),
        MaxPool((2,2)),
        Conv((3, 3), 512 => 512, relu, pad=(1, 1), stride=(1, 1)),
        BatchNorm(512),
        Conv((3, 3), 512 => 512, relu, pad=(1, 1), stride=(1, 1)),
        BatchNorm(512),
        Conv((3, 3), 512 => 512, relu, pad=(1, 1), stride=(1, 1)),
        BatchNorm(512),
        MaxPool((2,2)),
        flatten,
        Dense(512, 4096, relu),
        Dropout(0.5),
        Dense(4096, 4096, relu),
        Dropout(0.5),
        Dense(4096, 10)
    )
end

let model=vgg16(), x=rand(Float32, 32, 32, 3, 64)
    println("CPU benchmark")
    run_benchmark(model, x, cuda=false)
    println("CUDA benchmark")
    run_benchmark(model, x, cuda=true)
end


text:
using Distributions, Random, DataFrames, Statistics, LinearAlgebra, GLM, StatsBase, TimerOutputs, CSV

include("concentration_markov_header.jl")

F = 700
M = 35
exporter(F,M)

max_stars_repo_name: tyleransom/frictions-JHR

max_issues_repo_name: tyleransom/frictions-JHR

max_forks_repo_name: tyleransom/frictions-JHR


text:
function truncate_file(fname, size):
    open(fname, "r+") do f
        truncate(f, size)
    end
end

max_stars_repo_name: ethansaxenian/RosettaDecode

max_issues_repo_name: ethansaxenian/RosettaDecode

max_forks_repo_name: ethansaxenian/RosettaDecode


text:
module MvNormalMeanCovarianceTest

using Test
using ReactiveMP
using LinearAlgebra
using Distributions

@testset "MvNormalMeanCovariance" begin

    @testset "Constructor" begin
        @test MvNormalMeanCovariance <: AbstractMvNormal

        @test MvNormalMeanCovariance([ 1.0, 1.0 ]) == MvNormalMeanCovariance([ 1.0, 1.0 ], [ 1.0, 1.0 ])
        @test MvNormalMeanCovariance([ 1.0, 2.0 ]) == MvNormalMeanCovariance([ 1.0, 2.0 ], [ 1.0, 1.0 ])
        @test MvNormalMeanCovariance([ 1, 2 ])     == MvNormalMeanCovariance([ 1.0, 2.0 ], [ 1.0, 1.0 ])
        @test MvNormalMeanCovariance([ 1f0, 2f0 ]) == MvNormalMeanCovariance([ 1f0, 2f0 ], [ 1f0, 1f0 ])

        @test eltype(MvNormalMeanCovariance([ 1.0, 1.0 ]))               === Float64
        @test eltype(MvNormalMeanCovariance([ 1.0, 1.0 ], [ 1.0, 1.0 ])) === Float64
        @test eltype(MvNormalMeanCovariance([ 1, 1 ]))                   === Float64
        @test eltype(MvNormalMeanCovariance([ 1, 1 ], [ 1, 1 ]))         === Float64
        @test eltype(MvNormalMeanCovariance([ 1f0, 1f0 ]))               === Float32
        @test eltype(MvNormalMeanCovariance([ 1f0, 1f0 ], [ 1f0, 1f0 ])) === Float32
    end

    @testset "distrname" begin
        @test ReactiveMP.distrname(MvNormalMeanCovariance(zeros(2))) === "MvNormalMeanCovariance"
    end

    @testset "Stats methods" begin

        μ    = [ 0.2, 3.0, 4.0 ]
        Σ    = [ 1.5 -0.3 0.1; -0.3 1.8 0.0; 0.1 0.0 3.5 ]
        dist = MvNormalMeanCovariance(μ, Σ)

        @test mean(dist)         == μ
        @test mode(dist)         == μ
        @test weightedmean(dist) == cholinv(Σ) * μ
        @test invcov(dist)       ≈  cholinv(Σ)
        @test precision(dist)    ≈  cholinv(Σ)
        @test cov(dist)          == Σ
        @test std(dist)          ≈ cholsqrt(Σ)
        @test all(mean_cov(dist) .≈ (μ, Σ))
        @test all(mean_invcov(dist) .≈ (μ, cholinv(Σ)))
        @test all(mean_precision(dist) .≈ (μ, cholinv(Σ)))
        @test all(weightedmean_cov(dist) .≈ (cholinv(Σ) * μ, Σ))
        @test all(weightedmean_invcov(dist) .≈ (cholinv(Σ) * μ, cholinv(Σ)))
        @test all(weightedmean_precision(dist) .≈ (cholinv(Σ) * μ, cholinv(Σ)))

        @test length(dist) == 3
        @test entropy(dist) ≈ 5.361886000915401
        @test pdf(dist, [ 0.2, 3.0, 4.0 ])         ≈ 0.021028302702542
        @test pdf(dist,  [0.202, 3.002, 4.002])    ≈ 0.021028229679079503
        @test logpdf(dist, [ 0.2, 3.0, 4.0 ])      ≈ -3.8618860009154012
        @test logpdf(dist,  [0.202, 3.002, 4.002]) ≈ -3.861889473548943

    end

    @testset "Base methods" begin
        @test convert(MvNormalMeanCovariance{Float32}, MvNormalMeanCovariance([ 0.0, 0.0 ])) == MvNormalMeanCovariance([ 0f0, 0f0 ], [ 1f0, 1f0 ])
        @test convert(MvNormalMeanCovariance{Float64}, [ 0.0, 0.0 ], [ 2 0; 0 3 ]) == MvNormalMeanCovariance([ 0.0, 0.0 ], [ 2.0 0.0; 0.0 3.0 ])

        @test length(MvNormalMeanCovariance([ 0.0, 0.0 ]))      === 2
        @test length(MvNormalMeanCovariance([ 0.0, 0.0, 0.0 ])) === 3
        @test ndims(MvNormalMeanCovariance([ 0.0, 0.0 ]))       === 2
        @test ndims(MvNormalMeanCovariance([ 0.0, 0.0, 0.0 ]))  === 3
        @test size(MvNormalMeanCovariance([ 0.0, 0.0 ]))        === (2, )
        @test size(MvNormalMeanCovariance([ 0.0, 0.0, 0.0 ]))   === (3, )
    end

    @testset "vague" begin
        @test_throws MethodError vague(MvNormalMeanCovariance)

        d1 = vague(MvNormalMeanCovariance, 2)

        @test typeof(d1) <: MvNormalMeanCovariance
        @test mean(d1)  == zeros(2)
        @test cov(d1)   == Matrix(Diagonal(ReactiveMP.huge * ones(2)))
        @test ndims(d1) == 2

        d2 = vague(MvNormalMeanCovariance, 3)

        @test typeof(d2) <: MvNormalMeanCovariance
        @test mean(d2)  == zeros(3)
        @test cov(d2)   == Matrix(Diagonal(ReactiveMP.huge * ones(3)))
        @test ndims(d2) == 3
    end

    @testset "prod" begin

        @test prod(ProdAnalytical(), MvNormalMeanCovariance([ -1, -1 ], [ 2, 2 ]), MvNormalMeanCovariance([ 1, 1 ], [ 2, 4 ])) ≈ MvNormalWeightedMeanPrecision([ 0, -1/4 ], [ 1, 3/4])

        μ    = [ 1.0, 2.0, 3.0 ]
        Σ    = diagm([1.0, 2.0, 3.0])
        dist = MvNormalMeanCovariance(μ, Σ)

        @test prod(ProdAnalytical(), dist, dist) ≈ MvNormalWeightedMeanPrecision([2.0, 2.0, 2.0], diagm([2.0, 1.0, 2/3]))

    end

    @testset "Primitive types conversion" begin
        @test convert(MvNormalMeanCovariance, zeros(2), Matrix(Diagonal(ones(2)))) == MvNormalMeanCovariance(zeros(2), Matrix(Diagonal(ones(2))))
        @test begin
            m = rand(5)
            c = Matrix(Symmetric(rand(5, 5)))
            convert(MvNormalMeanCovariance, m, c) == MvNormalMeanCovariance(m, c)
        end
    end

end

end


text:
using REPL.TerminalMenus
import REPL.TerminalMenus: request

const has_treemenu = isdefined(TerminalMenus, :ConfiguredMenu)

if has_treemenu
    using FoldingTrees
end

mutable struct CthulhuMenu <: TerminalMenus.AbstractMenu
    options::Vector{String}
    pagesize::Int
    pageoffset::Int
    selected::Int
    toggle::Union{Nothing, Symbol}
    sub_menu::Bool
end

function show_as_line(el, optimize::Bool)
    reduced_displaysize = displaysize(stdout)::Tuple{Int,Int} .- (0, 3)
    buf = ctx = IOBuffer()
    if (color = get(stdout, :color, nothing)) !== nothing
        ctx = IOContext(ctx, :color=>color)
    end
    show(IOContext(ctx, :limit=>true, :displaysize=>reduced_displaysize, :optimize=>optimize), el)
    String(take!(buf))
end

function CthulhuMenu(callsites, optimize::Bool; pagesize::Int=10, sub_menu = false)
    options = vcat(map(site->show_as_line(site, optimize), callsites), ["↩"])
    length(options) < 1 && error("CthulhuMenu must have at least one option")

    # if pagesize is -1, use automatic paging
    pagesize = pagesize == -1 ? length(options) : pagesize
    # pagesize shouldn't be bigger than options
    pagesize = min(length(options), pagesize)
    # after other checks, pagesize must be greater than 1
    pagesize < 1 && error("pagesize must be >= 1")

    pageoffset = 0
    selected = -1 # none

    CthulhuMenu(options, pagesize, pageoffset, selected, nothing, sub_menu)
end

TerminalMenus.options(m::CthulhuMenu) = m.options
TerminalMenus.cancel(m::CthulhuMenu) = m.selected = -1

function TerminalMenus.header(m::CthulhuMenu)
    m.sub_menu && return ""
    """
    Select a call to descend into or ↩ to ascend. [q]uit. [b]ookmark.
    Toggles: [o]ptimize, [w]arn, [v]erbose printing for warntype code, [d]ebuginfo, [s]yntax highlight for Source/LLVM/Native.
    Show: [S]ource code, [A]ST, [L]LVM IR, [N]ative code
    Actions: [E]dit source code, [R]evise and redisplay
    Advanced: dump [P]arams cache.
    """
end

function TerminalMenus.keypress(m::CthulhuMenu, key::UInt32)
    m.sub_menu && return false
    if key == UInt32('w')
        m.toggle = :warn
        return true
    elseif key == UInt32('v')
        m.toggle = :verbose
        return true
    elseif key == UInt32('o')
        m.toggle = :optimize
        return true
    elseif key == UInt32('d')
        m.toggle = :debuginfo
        return true
    elseif key == UInt32('s')
        m.toggle = :highlighter
        return true
   elseif key == UInt32('S')
        m.toggle = :source
        return true
   elseif key == UInt32('A')
        m.toggle = :ast
        return true
    elseif key == UInt32('L')
        m.toggle = :llvm
        return true
    elseif key == UInt32('N')
        m.toggle = :native
        return true
    elseif key == UInt32('P')
        m.toggle = :dump_params
        return true
    elseif key == UInt32('b')
        m.toggle = :bookmark
        return true
    elseif key == UInt32('r') || key == UInt32('R')
        m.toggle = :revise
        return true
    elseif key == UInt32('e') || key == UInt32('E')
        m.toggle = :edit
        return true
    end
    return false
end

function TerminalMenus.pick(menu::CthulhuMenu, cursor::Int)
    menu.selected = cursor
    return true #break out of the menu
end

function TerminalMenus.writeLine(buf::IOBuffer, menu::CthulhuMenu, idx::Int, cursor::Bool)
    cursor_len = length(TerminalMenus.CONFIG[:cursor])
    # print a ">" on the selected entry
    cursor ? print(buf, TerminalMenus.CONFIG[:cursor]) : print(buf, repeat(" ", cursor_len))
    print(buf, " ") # Space between cursor and text

    line = replace(menu.options[idx], "\n" => "\\n")

    print(buf, line)
end

# This used to be the original method, the above is for compatibility with Base.REPL
function TerminalMenus.writeLine(buf::IOBuffer, menu::CthulhuMenu, idx::Int, cursor::Bool, term_width::Int)
    cursor_len = length(TerminalMenus.CONFIG[:cursor])
    # print a ">" on the selected entry
    cursor ? print(buf, TerminalMenus.CONFIG[:cursor]) : print(buf, repeat(" ", cursor_len))
    print(buf, " ") # Space between cursor and text

    line = replace(menu.options[idx], "\n" => "\\n")
    line = TerminalMenus.trimWidth(line, term_width, !cursor, cursor_len)

    print(buf, line)
end

function choose_method_instance(@nospecialize(sig); params=current_params())
    ci = callinfo(sig, Any, 1, params=params)
    ci isa MICallInfo && return get_mi(ci)
    ci isa Union{GeneratedCallInfo, FailedCallInfo} && return nothing
    if ci isa MultiCallInfo
        options = string.(ci.callinfos)
        menu = has_treemenu ? RadioMenu(options; charset=:unicode) : RadioMenu(options)
        chosen = request("Choose call to analyze:", menu)
        if chosen != -1
            return get_mi(ci.callinfos[chosen])
        end
    end
    error("unexpected callinfo ", ci)
end


text:
using ADCME
using PyPlot
using ProgressMeter
using Statistics

function f(x, σ)
    ε = randn(size(x)...) * σ
    return 10 * sin.(2π*x) + ε
end

batch_size = 32
noise = 1.0

X = reshape(LinRange(-0.5, 0.5, batch_size)|>Array, :, 1)
y = f(X, noise)
y_true = f(X, 0.0)

close("all")
scatter(X, y, marker="+", label="Training Data")
plot(X, y_true, label="Truth")
legend()
savefig("bnn_training_data.png")

mutable struct VariationalLayer
    units
    activation
    prior_σ1
    prior_σ2
    prior_π1
    prior_π2
    Wμ
    bμ
    Wρ
    bρ
    init_σ
end

function VariationalLayer(units; activation=relu, prior_σ1=1.5, prior_σ2=0.1,
        prior_π1=0.5)
    init_σ = sqrt(
        prior_π1 * prior_σ1^2 + (1-prior_π1)*prior_σ2^2
    )
    VariationalLayer(units, activation, prior_σ1, prior_σ2, prior_π1, 1-prior_π1,
                        missing, missing, missing, missing, init_σ)
end

function kl_loss(vl, w, μ, σ)
    dist = ADCME.Normal(μ,σ)
    return sum(logpdf(dist, w)-logprior(vl, w))
end

function logprior(vl, w)
    dist1 = ADCME.Normal(constant(0.0), vl.prior_σ1)
    dist2 = ADCME.Normal(constant(0.0), vl.prior_σ2)
    log(vl.prior_π1*exp(logpdf(dist1, w)) + vl.prior_π2*exp(logpdf(dist2, w)))
end

function (vl::VariationalLayer)(x)
    x = constant(x)
    if ismissing(vl.bμ)
        vl.Wμ = get_variable(vl.init_σ*randn(size(x,2), vl.units))
        vl.Wρ = get_variable(zeros(size(x,2), vl.units))
        vl.bμ = get_variable(vl.init_σ*randn(1, vl.units))
        vl.bρ = get_variable(zeros(1, vl.units))
    end
    Wσ = softplus(vl.Wρ)
    W = vl.Wμ + Wσ.*normal(size(vl.Wμ)...)
    bσ = softplus(vl.bρ)
    b = vl.bμ + bσ.*normal(size(vl.bμ)...)
    loss = kl_loss(vl, W, vl.Wμ, Wσ) + kl_loss(vl, b, vl.bμ, bσ)
    out = vl.activation(x * W + b)
    return out, loss
end

function neg_log_likelihood(y_obs, y_pred, σ)
    y_obs = constant(y_obs)
    dist = ADCME.Normal(y_pred, σ)
    sum(-logpdf(dist, y_obs))
end

ipt = placeholder(X)
x, loss1 = VariationalLayer(20, activation=relu)(ipt)
x, loss2 = VariationalLayer(20, activation=relu)(x)
x, loss3 = VariationalLayer(1, activation=x->x)(x)

loss_lf = neg_log_likelihood(y, x, noise)
loss = loss1 + loss2 + loss3 + loss_lf

opt = AdamOptimizer(0.08).minimize(loss)
sess = Session(); init(sess)
@showprogress for i = 1:5000
    run(sess, opt)
end

X_test = reshape(LinRange(-1.5,1.5,32)|>Array, :, 1)
y_pred_list = []
@showprogress for i = 1:10000
    y_pred = run(sess, x, ipt=>X_test)
    push!(y_pred_list, y_pred)
end

y_preds = hcat(y_pred_list...)

y_mean = mean(y_preds, dims=2)[:]
y_std = std(y_preds, dims=2)[:]

close("all")
plot(X_test, y_mean)
scatter(X[:], y[:], marker="+")
fill_between(X_test[:], y_mean-2y_std, y_mean+2y_std, alpha=0.5)
savefig("bnn_prediction.png")


text:
@doc """
	cgnr(A::Matrix, b::Vector, x0::Vector; prec, maxiter)

Conjugate gradient for normal equations residual method for solving the least squares problem `min norm( Ax - b )`.

- `A` is the coefficient matrix (`M-by-N`)
- `b` is the observation vector (`M`).
- `x0` is the starting vector (`N`).

The iteration stops when `norm(xnew - xold) < prec` or after at most `maxiter` iterations.
"""->
function cgnr{T<:Number}(A::AbstractMatrix{T}, b::AbstractVector{T}, x0::AbstractVector{T}; prec=LARGE_EPS, maxiter=length(x0))
	size(A,1) == length(b) || throw(DimensionMismatch())
	size(A,2) == length(x0) || throw(DimensionMismatch())
	prec >= SMALL_EPS || throw(DomainError())
	maxiter >= 1 || throw(DomainError())

	# Initialize
	x = copy(x0)
	y = A*x
	r = b - y
	z = A'*r
	p = copy(z)
	oneT = one(T)

	for iter = 1:maxiter
		ztz = norm(z)^2
		A_mul_B!(y, A, p) # y = A*p
		mu = ztz / norm(y)^2
		BLAS.axpy!(mu, p, x) # x = x + mu*p
		xdiff = mu*norm(p)

		BLAS.axpy!(-mu, y, r) # r = r - mu*y
		Ac_mul_B!(z, A, r) # z = A'*r
		tau = norm(z)^2 / ztz

		# p = z + tau*p
		scale!(p, tau)
		BLAS.axpy!(oneT, z, p)

		# Check for convergence: |xnew - xold|
		if xdiff < prec
			break
		end
	end

	return x
end

@doc """
	cgnr(T::Freq2wave, b, x0; ...) -> x

Conjugate gradient for normal equations residual method for `Freq2Wave`.
The initial point `x0` must be of the same dimension as `T`.
"""->
function cgnr(T::Freq2Wave, b::AbstractVector{Complex{Float64}}, x0::AbstractVecOrMat{Complex{Float64}}=zeros(eltype(T), wsize(T)); prec=LARGE_EPS, maxiter=max(length(x0),50))
	size(T,1) == length(b) || throw(DimensionMismatch())
	wsize(T) == size(x0) || throw(DimensionMismatch())
	prec >= SMALL_EPS || throw(DomainError())
	maxiter >= 1 || throw(DomainError())

	# Initialize
	x = copy(x0)
	y = T*x
	r = b - y
	z = T'*r
	p = copy(z)
	Cone = one(Complex{Float64})

	for iter = 1:maxiter
		ztz = vecnorm(z)^2
		A_mul_B!(y, T, p) # y = T*p
		mu = ztz / vecnorm(y)^2
		BLAS.axpy!(mu, p, x) # x = x + mu*p
		xdiff = mu*norm(p)

		BLAS.axpy!(-mu, y, r) # r = r - mu*y
		Ac_mul_B!(z, T, r) # z = T'*r
		tau = vecnorm(z)^2 / ztz

		# p = z + tau*p
		scale!(p, tau)
		BLAS.axpy!(Cone, z, p)

		# Check for convergence: |xnew - xold|
		if xdiff < prec
			break
		end
	end

	return x
end


text:
using InfiniteOpt, Ipopt, Plots
using KNITRO

# Parmeters
# Time span
t0 = 0
tf = 5
# Initial values
x10 = 0.7

x20 = 0.4

# Model
model = InfiniteModel(KNITRO.Optimizer)

# infinite_parameter
@infinite_parameter(model, t ∈ [t0, tf], num_supports = 101)

# variable
@variable(model, x1 ≥ 0, Infinite(t))
@variable(model, x2 ≥ 0, Infinite(t))

@variable(model, 0 ≤ u ≤ 1, Infinite(t), start = 0)

# objective
@objective(model, Max, ∫(log(x2), t))

# constraint
@constraint(model, x1(0) == x10)
@constraint(model, x2(0) == x20)
@constraint(model, x1_constr, ∂(x1, t) == u * x1)
@constraint(model, x2_constr, ∂(x2, t) == (1 - u) * x2)
@constraint(model, x1_min, x1 >= 0)
@constraint(model, x2_min, x2 >= 0)

# Optimization

print(model)

optimize!(model)

# Visulization
ts = value(t)
u = value(u)
x1 = value(x1)
x2 = value(x2)

plot(ts, u)
plot(ts, x1)
plot!(ts, x2)


text:
# Parts of this code were taken / derived from Graphs.jl. See LICENSE for
# licensing details.

# The concept and trivial implementation of graph visitors

abstract type SimpleGraphVisitor end

# trivial implementation

# invoked when a vertex v is encountered for the first time
# this function returns whether to continue search
discover_vertex!(vis::SimpleGraphVisitor, v) = true

# invoked when the algorithm is about to examine v's neighbors
open_vertex!(vis::SimpleGraphVisitor, v) = true

# invoked when a neighbor is discovered & examined
examine_neighbor!(vis::SimpleGraphVisitor, u, v, ucolor, vcolor, ecolor) = true

# invoked when all of v's neighbors have been examined
close_vertex!(vis::SimpleGraphVisitor, v) = true

struct TrivialGraphVisitor <: SimpleGraphVisitor end

# This is the common base for BreadthFirst and DepthFirst
abstract type SimpleGraphVisitAlgorithm end

###########################################################
#
#   General algorithms based on graph traversal
#
###########################################################

# List vertices by the order of being discovered

mutable struct VertexListVisitor <: SimpleGraphVisitor
    vertices::Vector{Int}

    function VertexListVisitor(n::Integer=0)
        vs = Vector{Int}()
        sizehint!(vs, n)
        new(vs)
    end
end

function discover_vertex!(visitor::VertexListVisitor, v)
    push!(visitor.vertices, v)
    return true
end

function visited_vertices(
    g::AGraphOrDiGraph,
    alg::SimpleGraphVisitAlgorithm,
    sources)

    visitor = VertexListVisitor(nv(g))
    traverse_graph!(g, alg, sources, visitor)
    return visitor.vertices
end

# Print visit log

mutable struct LogGraphVisitor{S<:IO} <: SimpleGraphVisitor
    io::S
end

function discover_vertex!(vis::LogGraphVisitor, v)
    println(vis.io, "discover vertex: $v")
    return true
end

function open_vertex!(vis::LogGraphVisitor, v)
    println(vis.io, "open vertex: $v")
    return true
end

function close_vertex!(vis::LogGraphVisitor, v)
    println(vis.io, "close vertex: $v")
    return true
end

function examine_neighbor!(vis::LogGraphVisitor, u, v, ucolor, vcolor, ecolor)
    println(vis.io, "examine neighbor: $u -> $v (ucolor = $ucolor, vcolor = $vcolor, edgecolor= $ecolor)")
    return true
end

function traverse_graph_withlog(
    g::AGraphOrDiGraph,
    alg::SimpleGraphVisitAlgorithm,
    sources,
    io::IO = stdout
)
    visitor = LogGraphVisitor(io)
    return traverse_graph!(g, alg, sources, visitor)
end


text:
# ---
# jupyter:
#   jupytext:
#     formats: ipynb,jl:hydrogen
#     text_representation:
#       extension: .jl
#       format_name: hydrogen
#       format_version: '1.3'
#       jupytext_version: 1.11.2
#   kernelspec:
#     display_name: Julia 1.6.2
#     language: julia
#     name: julia-1.6
# ---

# %%
using Plots
using Distributions

# %%
d = MixtureModel([Poisson(100), Poisson(250)], [0.95, 0.05])
n = 10^4
sample = sum.([rand(d, 20) for _ in 1:n])
histogram(sample)

# %%
using StatsPlots
x=rand(1:6, 10^5)
density(x; label="default")
density!(x; label="bandwidth=1", bandwidth=1)

# %%
using StatsPlots
x = rand(1:6, 10^5)
histogram(x; norm=true, alpha=0.3, bin=0.5:6.5, label="histogram of true sample")
density!(x; label="kde with bandwidth=1", bandwidth=1, lw=2)
plot!(; ylim=(-0.005, 0.22), xtick=-10:10)

# %%

max_stars_repo_path: 0017/StatsPlots density example.jl

max_stars_repo_name: genkuroki/public

max_issues_repo_path: 0017/StatsPlots density example.jl

max_issues_repo_name: genkuroki/public

max_forks_repo_path: 0017/StatsPlots density example.jl

max_forks_repo_name: genkuroki/public


text:
suffixes = Dict()
prefix = []

struct Markov
    order :: Int64
    suffixes :: Dict{Tuple{String, Vararg{String}}, Array{String, 1}}
    prefix :: Array{String, 1}
end

function Markov(order::Int64=2)
    new(order, Dict{Tuple{String, Vararg{String}}, Array{String, 1}}(), Array{String, 1}())
end

function processword(markov::Markov, word::String)
    if length(markov.prefix) < markov.order
        push!(markov.prefix, word)
        return
    end
end

# do blocks: page 226

data = "This here's the wattle,\nthe emblem of our land.\n"

open("output.txt", "w+") do fout
    write(fout, data)
end

f = (fout) -> begin
write(fout, data)


text:
# Bayesian multivariate student-t regression posterior abstract type

abstract SteinMultivariateStudentTRegressionPosterior <: SteinPosterior

# each row of betas is assumed to be a beta sample
function loglikelihood(d::SteinMultivariateStudentTRegressionPosterior,
                       beta::Array{Float64,1};
                       idx=1:length(d.y))
    X = d.X[idx,:]
    y = d.y[idx]
    nu = d.nu
    # Extract the number of observations
    m = size(X, 1)
    mus = y .- (X * beta)
    sigmainv_mus = \(d.sigma[idx,idx], mus)
    tpart = (mus' * sigmainv_mus)[1]

    logcons = lgamma(0.5 * (m + nu)) - lgamma(nu / 2) - (m/2)*log(nu*pi) -
        0.5 * logdet(d.sigma[idx,idx])
    logtterms = -0.5 * (m + nu) * log(1 + tpart / nu)

    logcons + logtterms
end

function gradloglikelihood(d::SteinMultivariateStudentTRegressionPosterior,
                           beta::Array{Float64,1};
                           idx=1:length(d.y))
    X = d.X[idx,:]
    y = d.y[idx]
    nu = d.nu
    # Extract the number of observations
    m = size(X, 1)
    # mus is a N x b matrix
    mus = y .- (X * beta)
    sigmainv_mus = \(d.sigma[idx,idx], mus)
    tpart = (mus' * sigmainv_mus)[1]

    tdistpart = 0.5 * (1 + m / nu) / (1 + tpart / nu)
    gradtpart = 2 * X' * sigmainv_mus
    # each column of gradients is the gradient for a given beta
    gradients = tdistpart .* gradtpart
    vec(gradients)
end


text:
import HTTP
import JSON

# https://juliaweb.github.io/HTTP.jl/dev

function sec_requests()
    r = HTTP.request("GET", "http://httpbin.org/ip") # = HTTP.get()

    #@show r.status
    #@show r.headers
    #@show String(r.body)

    #@info "Request body examples"
    #r = HTTP.post("http://httpbin.org/post", [], "post body data")
    #@show r.status
    #@show r.headers
    #@show String(r.body)
    @show r.body
    #str = String(r.body[1:end-1]) # need to remove last byte?
    str = String(r.body) # need to remove last byte?
    println(str)
    #@show JSON3.read(String(r.body))

    obj = JSON.parse(str)
    @show obj

    return r
end

function oildata()
    HTTP.request("PUT", "http://localhost:5000/vtk/v0/background/red")
    HTTP.request("PUT", "http://localhost:5000/vtk/v0/background/tan")
end

sec_requests()

nothing