我在Ipython中准备了一个小的演示,在这里我想展示在Julia中进行并行操作是多么的容易。
它基本上是蒙特卡洛Pi计算
问题是我不能让它在IPython (木星)笔记本中并行工作,它只使用一个。
我创办了朱莉娅:julia -p 4
如果我在REPL中定义了函数并在那里运行,它就能正常工作。
@everywhere function compute_pi(N::Int)
"""
Compute pi with a Monte Carlo simulation of N darts thrown in [-1,1]^2
Returns esti
我正在使用在Emacs下创建我的朱莉娅笔记本。然而,随着新的朱莉娅v1.0版本的发布,它不再工作了。
例如,这样一个基本的组织模式文档:
#+BEGIN_SRC julia :exports both :session mySession
1+2
#+END_SRC
返回空的#+RESULT
如果我查看mySession缓冲区,就会看到以下错误消息:
julia> ERROR: UndefVarError: writecsv not defined
Stacktrace:
[1] top-level scope at none:0
我要从朱莉娅0.7调到1.0。茱莉亚关于变量范围的规则似乎从0.7变到1.0。例如,我想运行这样一个简单的循环:
num = 0
for i = 1:5
if i == 3
num = num + 1
end
end
print(num)
在Julia0.7(和大多数其他语言中)中,我们可以期待循环之后的num = 1。然而,它将招致朱莉娅1.0中的UndefVarError: num not defined。我知道通过使用let我可以做到这一点
let
num = 0
for i = 1:5
if i == 3
num = num +
在朱莉娅中试图评估以下函数时,我遇到了一个错误(版本0.3.11,2015-0727 06:18 UTC,LinuxMint丽贝卡):
# this_script.jl
# global parameters
c = [ 1.0 , 2.0]
u = [-1.0 , 3.5]
# A simplified version of a more complicated function
function f(x,y)
xi = c .* (x/y - u)
1.0 + sum( erfi(xi) )
end
@vectorize_2arg Number f
我可以评估像f(2
我正在尝试使用pkg add安装julia Flux,并收到以下错误。 julia> Pkg.add("Flux")
ERROR: The following package names could not be resolved:
* Flux (not found in project, manifest or registry)
Please specify by known `name=uuid`.
Stacktrace:
[1] pkgerror(::String) at /buildworker/worke
Error: Error building `TensorFlow`:
│ ERROR: LoadError: UndefVarError: is_windows not defined
│ Stacktrace:
│ [1] top-level scope at none:0
│ [2] include at ./boot.jl:317 [inlined]
│ [3] include_relative(::Module, ::String) at ./loading.jl:1038
│ [4] include(::Module, ::String) at ./sysimg.jl:
我只想更改一个元素,如下面的代码所示。
using Flux, CuArrays
a = rand(3,3) |> gpu
CuArrays.allowscalar(false)
a[1, 1] = 1.0f0
因为标量被设置为false,所以它自然会出现在下面。
ERROR: scalar setindex! is disallowed
但是如果去掉了标量,它就会出现在下面。
Performing scalar operations on GPU arrays: This is very slow, consider disallowing these operations with
我想将每个元组Xp存储在不同的文件X1中,在mini_batch1.jld X2 in mini_batch2中.....但是我下面的代码在创建的文件中存储(复制)了Xp的所有元组。让我们看一个例子:
m= 100
k= 3 # number of tuples or partition
y=rand_gen(m,k)
(3,[[-1.0,1.0,1.0,1.0,-1.0,-1.0,1.0,-1.0,1.0,1.0,-1.0,-1.0,1.0,1.0,-1.0,-1.0,-1.0,1.0,-1.0,1.0,1.0,1.0,1.0,-1.0,-1.0,-1.0,1.0,1.0,1.0,-1.0
我有两个元组数组,我有一个循环,询问一个元素是否在另一个元素中。在每一步中,我都会问coord数组中包含的元组是否在Y数组中。该循环工作良好,除了一个元素,我无法解释为什么。以下是我所拥有的:
Y[55:65] # This is the array I want to check at each step if my state is in or not.
11-元素数组{Any,1}:(2.0,1.0) (3.0,1.0) (4.0,1.0) (5.0,1.0) (6.0,1.0) (7.0,1.0) (8.0,1.0) (9.0,1.0) (10.0,1.0) (11.0,1.0) (
我试图通过将变量的值插入到字符串中,从而在Julia中生成一个动态字符串。直到今天值返回nothing为止,一切都很好,给我留下了一个错误。
如何在字符串中包含nothing?至少,对于我想要插入到字符串中的每个变量,都不必经历一些if n == nothing; n = "None"问题。
function charge_summary(charges_df)
if size(charges_df)[1] > 0
n_charges = size(charges_df)[1]
total_charges = round(abs(s
我只需安装朱莉娅,然后JuliaPro为IDE。我可以让朱莉娅正常工作。然而,当我打开JuliaPro,我无法启动朱莉娅。我在按Enter键后收到了这条消息。
你知道发生了什么以及如何解决吗?
Press Enter to start Julia.
fatal: error thrown and no exception handler available.
InitError(mod=:BinaryProvider, error=ErrorException("No download engines found. We looked for: power
shell, C:\Wi
我正在尝试使用命令Pkg.add(PackageSpec(path = ""))在Julia中安装一个自定义包,该命令位于我的本地目录中。我使用创建了我的包。但是,每次我试图从本地路径使用安装自定义包时,都会引发一个错误。折页错误是-
Cloning git-repo `D:\df_sql\src\df_sql.jl`
ERROR: failed to clone from D:\df_sql\src\df_sql.jl, error: GitError(Code:ERROR, Class:Net, failed to resolve address for D: No suc
考虑Julia中的三值算子
julia> x = 1 ; y = 2
julia> println(x < y ? "less than" : "not less than")
less than
问题:有办法省略语句中的:部分吗?相当于
if condition
# dosomething
end
如果不满足条件,就不应该做任何事情。
注:我研究了答案,但没有出来,即使是在相关的问题(,)。