我正在为Akka Actor创建一个单元测试用例TestActorRef.
def actorRefFactory = context
implicit def executionContext = actorRefFactory.dispatcher
implicit val OutputActor = actorRefFactory.actorOf(Props[OutputActor], "OutputActor")
val actorRef = TestActorRef[OutputActor]
val actor = actorRef.underlyingActor
Run Code Online (Sandbox Code Playgroud)
在创建actorRef时出现以下错误:
- could not find implicit value for parameter system: akka.actor.ActorSystem
- not enough arguments for method apply: (implicit t:
scala.reflect.ClassTag[org.musigma.muhpc.OutputActor], implicit system:
akka.actor.ActorSystem)akka.testkit.TestActorRef[org.musigma.muhpc.OutputActor] in object
TestActorRef. Unspecified value parameter system.
Run Code Online (Sandbox Code Playgroud)
我对此很新.请帮助.
我正在尝试使用Tensorflow与结合使用的Python代码的可执行文件Pyinstaller。可执行文件正确生成,但是当我尝试运行它时,出现以下错误:
Traceback (most recent call last):
File "detection_init.py", line 14, in <module>
import lib.tensorboxDetector as tensorboxDetector
File "/usr/local/lib/python2.7/dist-packages/PyInstaller/loader/pyimod03_importers.py", line 396, in load_module
exec(bytecode, module.__dict__)
File "lib/tensorboxDetector.py", line 26, in <module>
from lib.train import build_forward
File "/usr/local/lib/python2.7/dist-packages/PyInstaller/loader/pyimod03_importers.py", line 396, in load_module
exec(bytecode, module.__dict__)
File "lib/train.py", line 4, in <module>
import tensorflow.contrib.slim as slim
File "/usr/local/lib/python2.7/dist-packages/PyInstaller/loader/pyimod03_importers.py", line 396, in load_module
exec(bytecode, module.__dict__)
File "tensorflow/contrib/__init__.py", line 22, in <module>
File "/usr/local/lib/python2.7/dist-packages/PyInstaller/loader/pyimod03_importers.py", line 396, in load_module
exec(bytecode, module.__dict__)
File "tensorflow/contrib/bayesflow/__init__.py", …Run Code Online (Sandbox Code Playgroud) 我是pyinstaller第一次尝试。我创建了一个hello.py仅用一行代码命名的文件:
print "hello"
Run Code Online (Sandbox Code Playgroud)
我使用以下命令制作二进制文件:
pyinstaller hello.py
Run Code Online (Sandbox Code Playgroud)
该过程成功完成,并在 上创建了一个二进制文件dist/hello。我无法运行这个二进制文件。当我试图从终端运行它时,我得到了,
bash: .: hello: cannot execute binary file
Run Code Online (Sandbox Code Playgroud)
我试图双击它,nautilus但没有任何反应。我怎样才能运行这个二进制文件?
我正在使用 Ubuntu 16.04
我要读命令行参数R通过Rscript,并使用存储在其中的一些整数运算的值.默认情况下,命令行参数作为字符导入:
#!/usr/bin/env Rscript
arg <- commandArgs(trailingOnly = TRUE)
x = as.vector(arg[1])
class(x)
x
y = as.vector(arg[2])
class(y)
y
cor.test(x,y)
Run Code Online (Sandbox Code Playgroud)
这是此脚本的输出:
$ Rscript Correlation.R 3,3,2 4,8,6
[1] "character"
[1] "3,3,2"
[1] "character"
[1] "4,8,6"
Error in cor.test.default(x, y) : 'x' must be a numeric vector
Calls: cor.test -> cor.test.default
Execution halted
Run Code Online (Sandbox Code Playgroud)
如何将x和y转换为数字向量?
我想在Apache Flink中创建流数据的时间窗口.我的数据看起来有点像这样:
1> {52,"mokshda",84.85}
2> {1,"kavita",26.16}
2> {131,"nidhi",178.9}
3> {2,"poorvi",22.97}
4> {115,"saheba",110.41}
Run Code Online (Sandbox Code Playgroud)
每隔20秒,我想要所有行的标记总和(最后一列,例如Mokshda的标记是84.85).timeWindow()函数在KeyedStream上运行,因此我必须使用keyBy()这个DataStream.我可以通过卷号(第一列,例如Mokshda的52)来键入它.
val windowedStream = stockStream
.keyBy(0)
.timeWindow(Time.seconds(20))
.sum(2)
Run Code Online (Sandbox Code Playgroud)
但显然,Flink并没有将我的数据作为列表读取.它将它作为String读取,因此,我得到以下异常:
Exception in thread "main" org.apache.flink.api.common.InvalidProgramException: Specifying keys via field positions is only valid for tuple data types. Type: String
Run Code Online (Sandbox Code Playgroud)
如何在String数据上执行timeWindow,或者如何将此数据转换为Tuple?
我在用Scala编写的Apache Flink API中创建了一个Kafka使用者.每当我从某个主题传递一些消息时,它就会接收它们.但是,当我重新启动使用者时,它会消耗发送到该主题的最新消息,而不是接收新消息或未消息消息.
这就是我在做的事情:
运行生产者:
$ bin/kafka-console-producer.sh --broker-list localhost:9092 --topic corr2
Run Code Online (Sandbox Code Playgroud)运行消费者:
val properties = new Properties()
properties.setProperty("bootstrap.servers", "localhost:9092")
properties.setProperty("zookeeper.connect", "localhost:2181")
properties.setProperty("group.id", "test")
val env = StreamExecutionEnvironment.getExecutionEnvironment
val st = env
.addSource(new FlinkKafkaConsumer09[String]("corr2", new SimpleStringSchema(), properties))
env.enableCheckpointing(5000)
st.print()
env.execute()
Run Code Online (Sandbox Code Playgroud)传递一些消息
我想在 Flink 中的 WindowedStream 上执行一些操作,比如平均操作。但可用的预定义操作非常有限,例如求和、最小值、最大值等。
val windowedStream = valueStream
.keyBy(0)
.timeWindow(Time.minutes(5))
.sum(2) //Change this to average?
Run Code Online (Sandbox Code Playgroud)
假设我想求平均值,我该怎么做呢?
我想在具有多个ps和worker的多GPU集群中试验TensorFlow的图形内复制.所述CIFAR-10多GPU示例示出了在一台机器上图形同步复制.是否有一个可用的示例,我可以参考示例培训程序进行图形间培训?
我正在尝试运行一个非常简单的Spark Streaming字数统计程序,该程序从一个Kafka主题读取。下面是我的代码:
val spark = SparkSession
.builder()
.appName("KafkaWordCount")
.config("spark.master", "local")
.getOrCreate()
import spark.implicits._
val df = spark
.readStream
.format("kafka")
.option("kafka.bootstrap.servers", "localhost:9092")
.option("subscribe", "test")
.load()
val lines = df.selectExpr("CAST(value AS STRING)").as[String]
val words = lines.flatMap(_.split(" "))
val wordCounts = words.groupBy("value").count()
val query = wordCounts.writeStream
.outputMode("complete")
.format("console")
.start()
query.awaitTermination()
Run Code Online (Sandbox Code Playgroud)
运行该程序时,出现以下异常:
Exception in thread "stream execution thread for [id = f704d6e5-14bf-4bd7-94a0-38c4b77986ea, runId = d277eaac-e18c-4128-954b-6a318bb8039c]" Exception in thread "main" java.lang.ExceptionInInitializerError
at org.apache.spark.rdd.RDD.withScope(RDD.scala:363)
at org.apache.spark.rdd.RDD.map(RDD.scala:370)
at org.apache.spark.sql.kafka010.KafkaSource.getBatch(KafkaSource.scala:287)
at org.apache.spark.sql.execution.streaming.MicroBatchExecution$$anonfun$org$apache$spark$sql$execution$streaming$MicroBatchExecution$$runBatch$1$$anonfun$apply$9.apply(MicroBatchExecution.scala:394)
at org.apache.spark.sql.execution.streaming.MicroBatchExecution$$anonfun$org$apache$spark$sql$execution$streaming$MicroBatchExecution$$runBatch$1$$anonfun$apply$9.apply(MicroBatchExecution.scala:390)
at scala.collection.TraversableLike$$anonfun$flatMap$1.apply(TraversableLike.scala:241) …Run Code Online (Sandbox Code Playgroud) 我想创建一个Trigger第一次在20秒内触发,此后每5秒触发一次的触发。我已经习惯GlobalWindows了Trigger
val windowedStream = valueStream
.keyBy(0)
.window(GlobalWindows.create())
.trigger(TradeTrigger.of())
Run Code Online (Sandbox Code Playgroud)
这是中的代码TradeTrigger:
@PublicEvolving
public class TradeTrigger<W extends Window> extends Trigger<Object, W> {
private static final long serialVersionUID = 1L;
static boolean flag=false;
static long ctime = System.currentTimeMillis();
private TradeTrigger() {
}
@Override
public TriggerResult onElement(
Object arg0,
long arg1,
W arg2,
org.apache.flink.streaming.api.windowing.triggers.Trigger.TriggerContext arg3)
throws Exception {
// TODO Auto-generated method stub
if(flag == false){
if((System.currentTimeMillis()-ctime) >= 20000){
flag = true;
ctime = System.currentTimeMillis();
return TriggerResult.FIRE;
} …Run Code Online (Sandbox Code Playgroud) 这个问题是关于TFDetect演示,它是Tensorflow Android Camera Demo的一部分.描述说,
演示基于可扩展对象检测的模型,使用深度神经网络实时定位和跟踪摄像机预览中的人员.
当我运行演示时,应用程序在检测到的对象周围创建了一个框,并为每个对象分配了一个小数(我猜是置信度得分).我的问题是,如何在这里执行跟踪.它是多个对象跟踪(在此描述),其中有一个id分配给每个轨道并且轨道存储在内存中,或者只是检测多个帧中的对象以查看对象是如何移动的?
如果我错过任何事情,请纠正我.
apache-flink ×4
tensorflow ×3
pyinstaller ×2
python ×2
scala ×2
actor ×1
akka ×1
android ×1
apache-kafka ×1
apache-spark ×1
linux ×1
r ×1
rscript ×1
sbt ×1