【发布时间】:2020-10-07 04:11:38
【问题描述】:
虽然我有 Python 和其他一些语言的经验,但我是 Julia 的初学者。我知道这可能是一个非常简单/初学者的问题,但我不明白它应该如何在 Julia 中工作。
我想创建一个 Julia 模块。我看到了使用PkgTemplates 创建它的建议,所以这正是我所做的。我的目录结构是这样的:
位于PkgTemplates建议的默认路径:/home/username/.julia/dev/Keras2Flux。
由于 Julia REPL 的启动时间很慢,我想用 Revise 包开发它。但是,我无法将我的模块导入终端中的 Julia REPL。
所以,我cd 到上面提到的目录,使用julia 命令并尝试using Keras2Flux。我得到了错误:
ERROR: ArgumentError: Package Keras2Flux not found in current path:
我尝试了using Keras2Flux 和using Keras2Flux.jl,还尝试从我的目录结构中的上一层调用它(即/home/username/.julia/dev)。所有人都有同样的问题。
出了什么问题(更重要的是,为什么?)以及如何解决?
模块的当前内容(与问题无关,但仍然):
module Keras2Flux
import JSON
using Flux
export convert
function create_dense(config)
in = config["input_dim"]
out = config["output_dim"]
dense = Dense(in, outо)
return dense
end
function create_dropout(config)
p = config["p"]
dropout = Dropout(p)
return dropout
end
function create_model(model_config)
layers = []
for layer_config in model_config
if layer_config["class_name"] == "Dense"
layer = create_dense(layer_config["config"])
elseif layer_config["class_name"] == "Dropout"
layer = create_dropout(layer_config["config"])
else
println(layer_config["class_name"])
throw("unimplemented")
end
push!(layers, layer)
end
model = Chain(layers)
end
function convert(filename)
jsontxt = ""
open(filename, "r") do f
jsontxt = read(f, String)
end
model_params = JSON.parse(jsontxt)
if model_params["keras_version"] == "1.1.0"
create_model(model_params["config"])
else
throw("unimplemented")
end
end
end
【问题讨论】:
-
你有没有
cded 进入包目录,] activate .在那里?