lib/tensorflow.rb in tensorflow-0.1.2 vs lib/tensorflow.rb in tensorflow-0.2.0

- old
+ new

@@ -41,15 +41,22 @@ require "tensorflow/keras/datasets/cifar100" require "tensorflow/keras/datasets/fashion_mnist" require "tensorflow/keras/datasets/imdb" require "tensorflow/keras/datasets/mnist" require "tensorflow/keras/datasets/reuters" +require "tensorflow/keras/layers/conv" +require "tensorflow/keras/layers/conv2d" require "tensorflow/keras/layers/dense" require "tensorflow/keras/layers/dropout" require "tensorflow/keras/layers/flatten" +require "tensorflow/keras/losses/sparse_categorical_crossentropy" require "tensorflow/keras/metrics/mean" +require "tensorflow/keras/metrics/sparse_categorical_accuracy" +require "tensorflow/keras/model" require "tensorflow/keras/models/sequential" +require "tensorflow/keras/optimizers/adam" +require "tensorflow/keras/preprocessing/image" require "tensorflow/keras/utils" module TensorFlow class Error < StandardError; end @@ -78,9 +85,12 @@ Tensor.new(value, dtype: dtype, shape: shape) end def convert_to_tensor(value, dtype: nil) value = Tensor.new(value, dtype: dtype) unless value.is_a?(Tensor) + if dtype && value.dtype != dtype + raise Error, "Tensor conversion requested dtype #{dtype} for Tensor with dtype #{value.dtype}" + end value end end end