tensorflow-hub

TimeDistributed of a KerasLayer in Tensorflow 2.0

醉酒当歌 提交于 2020-05-15 19:22:05
问题 I'm trying to build a CNN + RNN using a pre-trained model from tensorflow-hub: base_model = hub.KerasLayer('https://tfhub.dev/google/imagenet/resnet_v2_50/feature_vector/4', input_shape=(244, 244, 3) base_model.trainable = False model = Sequential() model.add(TimeDistributed(base_model, input_shape=(15, 244, 244, 3))) model.add(LSTM(512)) model.add(Dense(256, activation='relu')) model.add(Dense(3, activation='softmax')) adam = Adam(learning_rate=learning_rate) model.compile(loss='categorical

TimeDistributed of a KerasLayer in Tensorflow 2.0

こ雲淡風輕ζ 提交于 2020-05-15 19:21:08
问题 I'm trying to build a CNN + RNN using a pre-trained model from tensorflow-hub: base_model = hub.KerasLayer('https://tfhub.dev/google/imagenet/resnet_v2_50/feature_vector/4', input_shape=(244, 244, 3) base_model.trainable = False model = Sequential() model.add(TimeDistributed(base_model, input_shape=(15, 244, 244, 3))) model.add(LSTM(512)) model.add(Dense(256, activation='relu')) model.add(Dense(3, activation='softmax')) adam = Adam(learning_rate=learning_rate) model.compile(loss='categorical

Tensorflow Hub vs Keras application - performance drop

人走茶凉 提交于 2020-03-19 08:00:16
问题 I have image classification problem and i want to use Keras pretrained models for this task. When I use such a model model = tf.keras.Sequential([ hub.KerasLayer("https://tfhub.dev/google/tf2-preview/mobilenet_v2/feature_vector/4", output_shape=[1280], trainable=False), tf.keras.layers.Dropout(0.5), tf.keras.layers.Dense(num_classes, activation='softmax') ]) model.build([None, image_size[0], image_size[1], 3]) model.compile( optimizer=tf.keras.optimizers.Adam(), loss='categorical_crossentropy

Tensorflow Hub vs Keras application - performance drop

大城市里の小女人 提交于 2020-03-19 08:00:14
问题 I have image classification problem and i want to use Keras pretrained models for this task. When I use such a model model = tf.keras.Sequential([ hub.KerasLayer("https://tfhub.dev/google/tf2-preview/mobilenet_v2/feature_vector/4", output_shape=[1280], trainable=False), tf.keras.layers.Dropout(0.5), tf.keras.layers.Dense(num_classes, activation='softmax') ]) model.build([None, image_size[0], image_size[1], 3]) model.compile( optimizer=tf.keras.optimizers.Adam(), loss='categorical_crossentropy

How to combine a pre-trained KerasLayer from TensorFlow (v. 2) Hub and tfrecords?

て烟熏妆下的殇ゞ 提交于 2020-01-25 03:09:52
问题 I have a tfrecord with 23 classes with 35 images in each class (805 in total). My current tfrecord read function is: def read_tfrecord(serialized_example): feature_description = { 'image': tf.io.FixedLenFeature((), tf.string), 'label': tf.io.FixedLenFeature((), tf.int64), 'height': tf.io.FixedLenFeature((), tf.int64), 'width': tf.io.FixedLenFeature((), tf.int64), 'depth': tf.io.FixedLenFeature((), tf.int64) } example = tf.io.parse_single_example(serialized_example, feature_description) image

Memory leak when running universal-sentence-encoder-large itterating on dataframe

人走茶凉 提交于 2020-01-16 09:10:12
问题 I have 140K sentences I want to get embeddings for. I am using TF_HUB Universal Sentence Encoder and am iterating over the sentences(I know it's not the best way but when I try to feed over 500 sentences into the model it crashes). My Environment is: Ubuntu 18.04 Python 3.7.4 TF 1.14 Ram: 16gb processor: i-5 my code is: version 1 I iterate inside the tf.session context manager embed = hub.Module("https://tfhub.dev/google/universal-sentence-encoder-large/3") df = pandas_repository.get

Reproduce Tensorflow Hub module output with Tensorflow Slim

女生的网名这么多〃 提交于 2020-01-06 05:44:09
问题 I am trying to reproduce the output from a Tensorflow Hub module that is based on a Tensorflow Slim checkpoint, using the Tensorflow Slim modules. However, I can't seem to get the expected output. For example, let us load the required libraries, create a sample input and the placeholder to feed the data: import tensorflow_hub as hub from tensorflow.contrib.slim import nets images = np.random.rand(1,224,224,3).astype(np.float32) inputs = tf.placeholder(shape=[None, 224, 224, 3], dtype=tf

tensorflow_hub to pull BERT embedding on windows machine

孤人 提交于 2019-12-22 12:21:31
问题 I would like to get BERT embedding using tensorflow hub. I found it very easy to get ELMO embedding and my steps are below. Could anyone explain how to get BERT embedding on a windows machine? I found this but couldn't get it work on windows machine https://tfhub.dev/google/elmo/3 go to this link and then download. Unzip it twice till you see "tfhub_module.pb", provide path of that folder to get embedding import tensorflow as tf import tensorflow_hub as hub elmo = hub.Module("C:/Users/nnnn

Using tensorflow hub with go

陌路散爱 提交于 2019-12-20 07:19:10
问题 I want to use pre trained models in my go application. Especially the Inception-ResNet-v2 model. This model seems to be only available via tensorflow hub (https://www.tensorflow.org/hub/). However I could not find any documentation how to use tensorflow hub with the go language bindings for tensorflow. How can I download and use these models in go? 回答1: So after a lot of work in the past few days I finally found a way. At first I wanted to just use Python to do all the Tensorflow stuff and

Convert output of retrain.py to tensorflow.js

匆匆过客 提交于 2019-12-12 16:05:49
问题 The script retrain.py described in How to Retrain an Image Classifier for New Categories was run as python retrain.py --tfhub_module https://tfhub.dev/google/imagenet/mobilenet_v2_100_224/feature_vector/2 --image_dir /tmp/test and produced the output file /tmp/output_graph.pb . Converting this with tensorflowjs_converter --input_format=tf_saved_model --output_format=tfjs_graph_model /tmp/output_graph.pb /tmp/model failed with IOError: SavedModel file does not exist at: /tmp/output_graph.pb/