如何获取Julia变量的类型?

时间:2018-08-14 17:19:58

标签: julia

因此,我尝试阅读与code相关的简单Julia数组。我尝试了解一种lambda类型。

lambda = floatVar .* (Array_Int_3_A .^ 2 .+ Array_Int_3_B .^ 2 .+ Array_Int_3_C .^ 2);

会变成

lambda[i] = floatVar * (Array_Int_3_A[i]^2 + Array_Int_3_B[i]^2 + ...)

但是Array_Int_3_A是3个整数的数组,所以lambda也会是3个整数的数组吗? Julia中是否有一些工具或实用程序来显示函数变量类型?顺便说一句,有没有一种工具可以显示使用.作为更传统的数组样式代码的代码?

1 个答案:

答案 0 :(得分:2)

您可以通过h2o.init() h2o.no_progress() # y_train_processed_tbl is the target variable # x_train_processed_tbl is the remaining data post dealing with Missing # values data_h2o <- as.h2o(bind_cols(y_train_processed_tbl, x_train_processed_tbl)) splits_h2o <- h2o.splitFrame(data_h2o, ratios = c(0.7, 0.15), seed = 1234) train_h2o <- splits_h2o[[1]] valid_h2o <- splits_h2o[[2]] test_h2o <- splits_h2o[[3]] y <- "TARGET" x <- setdiff(names(train_h2o), y) automl_models_h2o <- h2o.automl(x = x,y = y, training_frame = train_h2o, validation_frame = valid_h2o, leaderboard_frame = test_h2o, max_runtime_secs = 90 ) automl_leader <- automl_models_h2o@leader # Error in performance_h2o performance_h2o <- h2o.performance(automl_leader, newdata = test_h2o) ERROR: Unexpected HTTP Status code: 404 Not Found water.exceptions.H2OKeyNotFoundArgumentException [1] "water.exceptions.H2OKeyNotFoundArgumentException: Object 'dummy' not found in function: predict for argument: model" [2] " water.api.ModelMetricsHandler.score(ModelMetricsHandler.java:235)" [3] " sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)" [4] " sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)" [5] " sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)" [6] " java.lang.reflect.Method.invoke(Unknown Source)" [7] " water.api.Handler.handle(Handler.java:63)" [8] " water.api.RequestServer.serve(RequestServer.java:451)" [9] " water.api.RequestServer.doGeneric(RequestServer.java:296)" [10] " water.api.RequestServer.doPost(RequestServer.java:222)" [11] " javax.servlet.http.HttpServlet.service(HttpServlet.java:755)" [12] " javax.servlet.http.HttpServlet.service(HttpServlet.java:848)" [13] " org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:684)" [14] " org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:503)" [15] " org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1086)" [16] " org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:429)" [17] " org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1020)" [18] " org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)" [19] " org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:154)" [20] " org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)" [21] " water.JettyHTTPD$LoginHandler.handle(JettyHTTPD.java:197)" [22] " org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:154)" [23] " org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)" [24] " org.eclipse.jetty.server.Server.handle(Server.java:370)" [25] " org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:494)" [26] " org.eclipse.jetty.server.BlockingHttpConnection.handleRequest(BlockingHttpConnection.java:53)" [27] " org.eclipse.jetty.server.AbstractHttpConnection.content(AbstractHttpConnection.java:982)" [28] " org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.content(AbstractHttpConnection.java:1043)" [29] " org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:865)" [30] " org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:240)" [31] " org.eclipse.jetty.server.BlockingHttpConnection.handle(BlockingHttpConnection.java:72)" [32] " org.eclipse.jetty.server.bio.SocketConnector$ConnectorEndPoint.run(SocketConnector.java:264)" [33] " org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)" [34] " org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)" [35] " java.lang.Thread.run(Unknown Source)" Error in .h2o.doSafeREST(h2oRestApiVersion = h2oRestApiVersion, urlSuffix = page, : ERROR MESSAGE: Object 'dummy' not found in function: predict for argument: model 获得任何Julia对象o的类型。

typeof(o)

在您的代码行中,所有圆点仅表示“逐个应用操作”。因此,类型(和大小)不会改变。

此外,在这里准确地说,help?> typeof search: typeof typejoin TypeError typeof(x) Get the concrete type of x. Examples ≡≡≡≡≡≡≡≡≡≡ julia> a = 1//2; julia> typeof(a) Rational{Int64} julia> M = [1 2; 3.5 4]; julia> typeof(M) Array{Float64,2} 的含义不是“ 3个整数的数组”,而是“ 3维数组”,在这两个维中的任何一个都可以具有任意范围。要获取数组的范围或大小,可以使用Array{Int,3}