Comments (3)
Unfortunately, Java API support in TF has been spotty with deprecation warnings and no API stability guarantees. We initially tried to support Java when the API was updated regularly with each TF release, but even then, it was mostly geared towards inference and not training. That said, contributions are always welcome!
from tensorflowonspark.
Unfortunately, Java API support in TF has been spotty with deprecation warnings and no API stability guarantees. We initially tried to support Java when the API was updated regularly with each TF release, but even then, it was mostly geared towards inference and not training. That said, contributions are always welcome!
for me when I read our source code ,I was inspired by these scala code in TFModel, we do the model implement spark Model Interface api, tensor convert df and df convert to tensor ,and invoke tensorflow session, and get the distribute partition block ,mapPartition do model train,collect all partitions result for one model
override def transform(dataset: Dataset[_]): DataFrame = {
val spark = dataset.sparkSession
val inputColumns = this.getInputMapping.keys.toSeq
val inputTensorNames = this.getInputMapping.values
val outputTensorNames = this.getOutputMapping.keys.toSeq
val inputDF = dataset.select(inputColumns.head, inputColumns.tail: _*)
val inputSchema = inputDF.schema
val outputSchema = transformSchema(inputSchema)
val outputRDD = inputDF.rdd.mapPartitions { iter: Iterator[Row] =>
if (TFModel.model == null || TFModel.modelDir != this.getModel) {
// load model into a per-executor singleton reference, if needed.
TFModel.modelDir = this.getModel
TFModel.model = SavedModelBundle.load(this.getModel, this.getTag)
TFModel.graph = TFModel.model.graph
TFModel.sess = TFModel.model.session
}
iter.grouped(this.getBatchSize).flatMap { batch =>
// get input batch of Rows and convert to list of input Tensors
val inputTensors = batch2tensors(batch, inputSchema)
var runner = TFModel.sess.runner()
// feed input tensors
for ((name, tensor) <- inputTensors) {
runner = runner.feed(this.getInputMapping(name), tensor)
}
// fetch output tensors
for (name <- outputTensorNames) {
runner = runner.fetch(name)
}
// run the graph
val outputTensors = runner.run()
assert(outputTensors.map(_.shape).map(s => if (s.isEmpty) 0L else s.apply(0)).distinct.size == 1,
"Cardinality of output tensors must match")
// convert the list of output Tensors to a batch of output Rows
tensors2batch(outputTensors)
}
}
spark.createDataFrame(outputRDD, outputSchema)
}
from tensorflowonspark.
got an error "Could not find SavedModel .pb" when submit on yarn cluster at code "TFModel.model = SavedModelBundle.load(this.getModel, this.getTag)"
from tensorflowonspark.
Related Issues (20)
- Writing checkpoints to HDFS takes long HOT 2
- when using mnist_spark.py , serializer.dump_stream Timeout while feeding partition HOT 2
- pkg_resources.DistributionNotFound: The 'tensorflow' distribution was not found and is required by the application HOT 3
- MNIST example - Exception in TF background thread HOT 2
- the doubt about the data policy HOT 1
- Performance issues in the program HOT 2
- Performance issues in examples/mnist/estimator (by P3) HOT 3
- Retaining original columns after inference HOT 2
- tensorflow.python.framework.errors_impl.UnimplementedError: File system scheme 'cosn' not implemented HOT 2
- Model Saved with TF-2.5.0 HOT 3
- How to integrate a model into Spark cluster HOT 12
- Get stuck at "Added broadcast_0_piece0 in memory on" while runing Spark standalone cluster HOT 1
- ExitCode: 13 executing mnist_data_setup.py on a yarn cluster HOT 3
- can it run on tensorflow-cpu? HOT 1
- can it run use ParameterServerStrategy HOT 3
- Evalator hangs while training HOT 1
- yarn mode error HOT 1
- error while running mnist_tf_ds.py HOT 1
- I have been trying to use TensorFlowOnSpark in Azure Synapse Analytics and I would like to ask if you have any information about its compatibility in this environment
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tensorflowonspark.