From 7720af0afd8f476903f0352186973dd2057c0475 Mon Sep 17 00:00:00 2001 From: fkm3 Date: Thu, 19 Oct 2017 13:41:55 -0400 Subject: [PATCH] Update to tensorflow 1.3 (#161) * Tested on linux without Docker. * Couldn't get nix build to work, so I just updated the URL and hash. * Did not test macos build. The mnist change was necessary because the argmax output type is now polmorphic. --- ChangeLog.md | 1 + ci_build/Dockerfile | 4 ++-- docker/Dockerfile | 4 ++-- tensorflow-core-ops/Setup.hs | 9 ++++++++- tensorflow-mnist/app/Main.hs | 3 ++- tensorflow-proto/tensorflow-proto.cabal | 4 +++- tensorflow/src/TensorFlow/Types.hs | 4 +++- third_party/tensorflow | 2 +- tools/install_macos_dependencies.sh | 2 +- tools/userchroot.nix | 5 ++--- 10 files changed, 25 insertions(+), 13 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index be60358..e68a080 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,6 +1,7 @@ # ChangeLog ## Upcoming (v0.2.0.0) +- Switch to tensorflow 1.3. - Expand the `Rendered` class and add a `ToTensor` class to let more functions (gradients, feed, colocateWith) support `ResourceHandle` wrappers like `Variables`. diff --git a/ci_build/Dockerfile b/ci_build/Dockerfile index fa19316..ffc0cd2 100644 --- a/ci_build/Dockerfile +++ b/ci_build/Dockerfile @@ -28,8 +28,8 @@ RUN \ curl -O -L https://github.com/google/protobuf/releases/download/v3.2.0/protoc-3.2.0-linux-x86_64.zip && \ unzip -d /usr/local protoc-3.2.0-linux-x86_64.zip bin/protoc && \ chmod 755 /usr/local/bin/protoc && \ - curl -O https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-linux-x86_64-1.0.0.tar.gz && \ - tar zxf libtensorflow-cpu-linux-x86_64-1.0.0.tar.gz -C /usr/local && \ + curl -O https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-linux-x86_64-1.3.0.tar.gz && \ + tar zxf libtensorflow-cpu-linux-x86_64-1.3.0.tar.gz -C /usr/local && \ ldconfig && \ stack setup && \ stack test --only-dependencies diff --git a/docker/Dockerfile b/docker/Dockerfile index f39982d..f08237a 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -25,8 +25,8 @@ RUN \ curl -O -L https://github.com/google/protobuf/releases/download/v3.2.0/protoc-3.2.0-linux-x86_64.zip && \ unzip -d /usr/local protoc-3.2.0-linux-x86_64.zip bin/protoc && \ chmod 755 /usr/local/bin/protoc && \ - curl -O https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-linux-x86_64-1.0.0.tar.gz && \ - tar zxf libtensorflow-cpu-linux-x86_64-1.0.0.tar.gz -C /usr/local && \ + curl -O https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-linux-x86_64-1.3.0.tar.gz && \ + tar zxf libtensorflow-cpu-linux-x86_64-1.3.0.tar.gz -C /usr/local && \ ldconfig ENV LANG en_US.UTF-8 diff --git a/tensorflow-core-ops/Setup.hs b/tensorflow-core-ops/Setup.hs index efc0dce..7be49a7 100644 --- a/tensorflow-core-ops/Setup.hs +++ b/tensorflow-core-ops/Setup.hs @@ -90,7 +90,14 @@ fudgePackageDesc lbi p = p blackList = [ -- Requires the "func" type: - "SymbolicGradient" + "FilterDataset" + , "FlatMapDataset" + , "GroupByWindowDataset" + , "InterleaveDataset" + , "MapDataset" + , "OneShotIterator" + , "ParallelMapDataset" + , "SymbolicGradient" ] autogenModulesDir :: LocalBuildInfo -> FilePath diff --git a/tensorflow-mnist/app/Main.hs b/tensorflow-mnist/app/Main.hs index 101ce0a..a2361cf 100644 --- a/tensorflow-mnist/app/Main.hs +++ b/tensorflow-mnist/app/Main.hs @@ -14,6 +14,7 @@ {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE OverloadedLists #-} +{-# LANGUAGE TypeApplications #-} import Control.Monad (forM_, when) import Control.Monad.IO.Class (liftIO) @@ -75,7 +76,7 @@ createModel = do logitBiases <- TF.zeroInitializedVariable [numLabels] let logits = (hidden `TF.matMul` TF.readValue logitWeights) `TF.add` TF.readValue logitBiases - predict <- TF.render $ TF.cast $ + predict <- TF.render @TF.Build @LabelType $ TF.argMax (TF.softmax logits) (TF.scalar (1 :: LabelType)) -- Create training action. diff --git a/tensorflow-proto/tensorflow-proto.cabal b/tensorflow-proto/tensorflow-proto.cabal index ad6b381..b1d53d6 100644 --- a/tensorflow-proto/tensorflow-proto.cabal +++ b/tensorflow-proto/tensorflow-proto.cabal @@ -42,15 +42,17 @@ library , Proto.Tensorflow.Core.Framework.Variable , Proto.Tensorflow.Core.Framework.Versions , Proto.Tensorflow.Core.Lib.Core.ErrorCodes + , Proto.Tensorflow.Core.Protobuf.Cluster , Proto.Tensorflow.Core.Protobuf.Config , Proto.Tensorflow.Core.Protobuf.ControlFlow , Proto.Tensorflow.Core.Protobuf.Debug , Proto.Tensorflow.Core.Protobuf.MetaGraph , Proto.Tensorflow.Core.Protobuf.NamedTensor , Proto.Tensorflow.Core.Protobuf.QueueRunner - , Proto.Tensorflow.Core.Protobuf.TensorBundle + , Proto.Tensorflow.Core.Protobuf.RewriterConfig , Proto.Tensorflow.Core.Protobuf.SavedModel , Proto.Tensorflow.Core.Protobuf.Saver + , Proto.Tensorflow.Core.Protobuf.TensorBundle , Proto.Tensorflow.Core.Protobuf.TensorflowServer , Proto.Tensorflow.Core.Util.Event , Proto.Tensorflow.Core.Util.MemmappedFileSystem diff --git a/tensorflow/src/TensorFlow/Types.hs b/tensorflow/src/TensorFlow/Types.hs index 60cf697..8c82cce 100644 --- a/tensorflow/src/TensorFlow/Types.hs +++ b/tensorflow/src/TensorFlow/Types.hs @@ -97,7 +97,7 @@ import Proto.Tensorflow.Core.Framework.AttrValue , tensor ) import Proto.Tensorflow.Core.Framework.ResourceHandle - (ResourceHandle) + (ResourceHandleProto) import Proto.Tensorflow.Core.Framework.Tensor as Tensor ( TensorProto(..) , boolVal @@ -119,6 +119,8 @@ import Proto.Tensorflow.Core.Framework.Types (DataType(..)) import TensorFlow.Internal.VarInt (getVarInt, putVarInt) import qualified TensorFlow.Internal.FFI as FFI +type ResourceHandle = ResourceHandleProto + -- | The class of scalar types supported by tensorflow. class TensorType a where tensorType :: a -> DataType diff --git a/third_party/tensorflow b/third_party/tensorflow index 0c68156..408fd45 160000 --- a/third_party/tensorflow +++ b/third_party/tensorflow @@ -1 +1 @@ -Subproject commit 0c68156ffcf918df905f9f39a632888724c66c3b +Subproject commit 408fd454d7d2a16269576ea12bcd516e25a6b0c5 diff --git a/tools/install_macos_dependencies.sh b/tools/install_macos_dependencies.sh index ec78e42..742d763 100755 --- a/tools/install_macos_dependencies.sh +++ b/tools/install_macos_dependencies.sh @@ -25,7 +25,7 @@ else fi echo "Downloading libtensorflow..." -curl https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-darwin-x86_64-1.0.0.tar.gz > libtensorflow.tar.gz +curl https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-darwin-x86_64-1.3.0.tar.gz > libtensorflow.tar.gz echo "Extracting and copying libtensorflow..." sudo tar zxf libtensorflow.tar.gz -C /usr/local diff --git a/tools/userchroot.nix b/tools/userchroot.nix index 804a25b..74907f7 100644 --- a/tools/userchroot.nix +++ b/tools/userchroot.nix @@ -13,8 +13,8 @@ let name = "tensorflow-c"; src = fetchurl { - url = "https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-linux-x86_64-1.0.0.tar.gz"; - sha256 = "1kmss9wdri5ibd19b4ymh2dvajw5cy34bxzxlaa5i60hiwpppljy"; + url = "https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-linux-x86_64-1.3.0.tar.gz"; + sha256 = "1d4bda5316063b70cf50a668d774b2067ef2a8ab163ff2eb29592bf3c24e2183"; }; buildCommand = '' @@ -63,4 +63,3 @@ stdenv.mkDerivation { nativeBuildInputs = [ fhs ]; shellHook = "exec fhs"; } -