tensorflow-hub

Tensorflow Hub Inception V3 structure compared to Keras Inception V3 structure?

戏子无情 提交于 2019-12-11 17:19:19
问题 I have been working Keras Inception V3. I believe the Keras model structure looks like the image below. But when I use the Inception V3 model from Tensorflow Hub, I think (but am not sure) that the TF-Hub Inception V3 model includes up until the Mixed7 output of IV3 (the 7th red "Concat" box), where Keras, in contrast, includes up to the Mixed10 output (10th red "Concat" box). Can someone confirm? (or deny!) the structure of the Tensorflow Hub Inception V3 Feature Vector model? Can someone

ValueError: Input 0 of layer dense is incompatible with the layer: its rank is undefined, but the layer requires a defined rank

断了今生、忘了曾经 提交于 2019-12-11 14:51:32
问题 When trying the example at https://www.tensorflow.org/tutorials/images/hub_with_keras at a local computer with tf '2.0.0-alpha0' (download, pip -download hub '0.4.0-dev' and remove !pip... lines, install tf 2, remove enable_v2_behavior , run file), it failed with ValueError: Input 0 of layer dense is incompatible with the layer: its rank is undefined, but the layer requires a defined rank. It runs fine on Google colab though. Why is this and how can it be fixed? 回答1: As proposed by @arnoegw

Tensorflow hub fine-tune and evaluate

天大地大妈咪最大 提交于 2019-12-11 05:31:22
问题 I want to use tensorflow hub, to retrain one of its modules in my graph and then use that module, but my problem is when I set trainable = True and tags = {"train"} to create the module, I can not do an evaluation because of batch normalization layers. so as I read about this issue, I found that I should create also another graph for evaluation without setting tags = {"train"} . but I don't know how to restore variables from train graph into eval graph. I tried creating both modules with the

Tensorflow: Module must be applied in the graph it was instantiated for

会有一股神秘感。 提交于 2019-12-11 04:14:52
问题 I'm trying to serve universal sentence encoder with Django. The code is initialized in the beginning as a background process (by using programs such as supervisor), then it communicates with Django using TCP sockets and eventually returns encoded sentence. import socket from threading import Thread import tensorflow as tf import tensorflow_hub as hub import atexit # Pre-loading the variables: embed = hub.Module("https://tfhub.dev/google/universal-sentence-encoder/2") session = tf.Session()

Strongly increasing memory consumption when using ELMo from Tensorflow-Hub

蹲街弑〆低调 提交于 2019-12-02 07:45:23
问题 I am currently trying to compare the similarity of millions of documents. For a first test on a CPU I reduced them to around 50 characters each and try to get the ELMo Embedding for 10 of them at a time like this: ELMO = "https://tfhub.dev/google/elmo/2" for row in file: split = row.split(";", 1) if len(split) > 1: text = split[1].replace("\n", "") texts.append(text[:50]) if i == 300: break if i % 10 == 0: elmo = hub.Module(ELMO, trainable=False) executable = elmo( texts, signature="default",

Strongly increasing memory consumption when using ELMo from Tensorflow-Hub

℡╲_俬逩灬. 提交于 2019-12-02 05:35:49
I am currently trying to compare the similarity of millions of documents. For a first test on a CPU I reduced them to around 50 characters each and try to get the ELMo Embedding for 10 of them at a time like this: ELMO = "https://tfhub.dev/google/elmo/2" for row in file: split = row.split(";", 1) if len(split) > 1: text = split[1].replace("\n", "") texts.append(text[:50]) if i == 300: break if i % 10 == 0: elmo = hub.Module(ELMO, trainable=False) executable = elmo( texts, signature="default", as_dict=True)["elmo"] vectors = execute(executable) texts = [] i += 1 However, even with this small

Tensorflow Hub: Fine-tune and evaluate

♀尐吖头ヾ 提交于 2019-11-29 16:39:58
Let's say that I want to fine tune one of the Tensorflow Hub image feature vector modules. The problem arises because in order to fine-tune a module, the following needs to be done: module = hub.Module("https://tfhub.dev/google/imagenet/resnet_v2_50/feature_vector/3", trainable=True, tags={"train"}) Assuming that the module is Resnet50 . In other words, the module is imported with the trainable flag set as True and with the train tag . Now, in case I want to validate the model (perform inference on the validation set in order to measure the performance of the model), I can't switch off the

Tensorflow Hub: Fine-tune and evaluate

扶醉桌前 提交于 2019-11-28 10:39:23
问题 Let's say that I want to fine tune one of the Tensorflow Hub image feature vector modules. The problem arises because in order to fine-tune a module, the following needs to be done: module = hub.Module("https://tfhub.dev/google/imagenet/resnet_v2_50/feature_vector/3", trainable=True, tags={"train"}) Assuming that the module is Resnet50 . In other words, the module is imported with the trainable flag set as True and with the train tag . Now, in case I want to validate the model (perform