Categories
Misc

Tensorboard: Should I be using the smoothed or normal value for evaluating accuracy?

Hi Everyone,

Pretty much in the title. I’m pretty sure that the smoothed
values are some sort of exponential moving average.

When evaluating the accuracy of the model (say, the accuracy I
want to tell people my model can achieve on the validation set, for
some nth epoch), should I be using the smoothed value or the normal
value? I take the accuracy every epoch.

Of course, this is before the ultimate test on the test set, but
before doing that, to kind of figure out what my max accuracy is,
and to gauge if the hyperparamaters i’m choosing are working,
should I be going by the smoothed or not smoothed values?

An example:

On step no. 151 (epoch 8)

smoothed accuracy (with smooth = 0.6) is 36.25%

“real” accuracy is 42.86%

Is my actual accuracy 36.25% or 42.86%? i

Thanks!

A

submitted by /u/kirbyburgers

[visit reddit]

[comments]

Categories
Misc

Does my model make sense? It’s looking thicc but I don’t know

I’ve built my first model and I’ve not very experienced so I’m
unsure if it’s structured correctly.

I have the VGG16 model on top (frozen) and I connect this to a
dene layer that I train on categorical data (6 classes)

_________________________________________________________________ Model: "model" _________________________________________________________________ Layer (type) Output Shape Param # ================================================================= input_1 (InputLayer) [(None, 150, 150, 3)] 0 _________________________________________________________________ block1_conv1 (Conv2D) (None, 150, 150, 64) 1792 _________________________________________________________________ block1_conv2 (Conv2D) (None, 150, 150, 64) 36928 _________________________________________________________________ block1_pool (MaxPooling2D) (None, 75, 75, 64) 0 _________________________________________________________________ block2_conv1 (Conv2D) (None, 75, 75, 128) 73856 _________________________________________________________________ block2_conv2 (Conv2D) (None, 75, 75, 128) 147584 _________________________________________________________________ block2_pool (MaxPooling2D) (None, 37, 37, 128) 0 _________________________________________________________________ block3_conv1 (Conv2D) (None, 37, 37, 256) 295168 _________________________________________________________________ block3_conv2 (Conv2D) (None, 37, 37, 256) 590080 _________________________________________________________________ block3_conv3 (Conv2D) (None, 37, 37, 256) 590080 _________________________________________________________________ block3_pool (MaxPooling2D) (None, 18, 18, 256) 0 _________________________________________________________________ block4_conv1 (Conv2D) (None, 18, 18, 512) 1180160 _________________________________________________________________ block4_conv2 (Conv2D) (None, 18, 18, 512) 2359808 _________________________________________________________________ block4_conv3 (Conv2D) (None, 18, 18, 512) 2359808 _________________________________________________________________ block4_pool (MaxPooling2D) (None, 9, 9, 512) 0 _________________________________________________________________ block5_conv1 (Conv2D) (None, 9, 9, 512) 2359808 _________________________________________________________________ block5_conv2 (Conv2D) (None, 9, 9, 512) 2359808 _________________________________________________________________ block5_conv3 (Conv2D) (None, 9, 9, 512) 2359808 _________________________________________________________________ block5_pool (MaxPooling2D) (None, 4, 4, 512) 0 _________________________________________________________________ flatten (Flatten) (None, 8192) 0 _________________________________________________________________ dense (Dense) (None, 128) 1048704 _________________________________________________________________ dense_1 (Dense) (None, 6) 774 ================================================================= Total params: 15,764,166 Trainable params: 1,049,478 Non-trainable params: 14,714,688 _________________________________________________________________ 

I want to apply what the model has learnt thus far to a binary
classification problem. So, once trained on my categorical data, I
freeze `dense` and remove `dense_1`, then I add in `dense_2`,
`dense_3`, `dense_4` (the latter having 1 output).

continued from before.... block5_pool (MaxPooling2D) (None, 4, 4, 512) 0 _________________________________________________________________ flatten (Flatten) (None, 8192) 0 _________________________________________________________________ dense (Dense) (None, 128) 1048704 _________________________________________________________________ dense_2 (Dense) (None, 128) 16512 _________________________________________________________________ dense_3 (Dense) (None, 128) 16512 _________________________________________________________________ dense_4 (Dense) (None, 1) 129 ================================================================= Total params: 15,796,545 Trainable params: 33,153 Non-trainable params: 15,763,392 

Then I train it on my binary data (I have setup augmentation and
preprocessing, etc.)

Does this network make sense though? I don’t have the deep
understanding many people here do, so not really sure. Any input
would be appreciated.

submitted by /u/BananaCharmer

[visit reddit]

[comments]

Categories
Misc

How to get the equation that a multiple linear regression model is using in Keras w/ Tensorflow?

I have the weights and biases for both the normalizer and the
Dense layer in my model, but I am unsure how to convert these
values into 1 equation that the computer is using to predict
values, which I would like to know. The model takes 2 independent
values and predicts 1 value, so using the weights and biases below,
how I could formulate an equation:

weights for normalizer layer: [ 8.89 11.5 ]

biases for normalizer layer: [321.69 357.53]

(not even sure if the normalizer biases and weights matter as it
is part of preprocessing)

weights for Dense layer: [[ 0.08] [19.3 ]]

biases for Dense layer: [11.54]

Thank you very much and I would greatly appreciate any help!
🙂

submitted by /u/HexadecimalHero

[visit reddit]

[comments]

Categories
Misc

Any pre-trained TensorFlow models on speech/voice data?

Hi All,

I have been looking for TensorFlow models pre-trained on speech
data, preferably in js/python. That I can use to extract embeddings
for streaming/recorded audio up to 1 min long.

I intend to use the embeddings as an input to my machine
learning pipeline.

So far, I have found only this:


https://github.com/tensorflow/tfjs-models/tree/master/speech-commands

This is trained to classify 20 voice commands. So, I feel the
embeddings from this model may not have sufficient discriminative
power to identify, let’s say – phonemes, 1000 words each from
English, French and a few other popular languages.

I am not worried about embedding->word mapping. At the
current stage, I am happy to use the embeddings to evaluate
similarity score of two different sound samples. E.g. I am not
worried about resolving confusion between – ‘red’ and ‘read(past
tense)’. In fact – ‘I read a red book’ ‘Eye red a read buk’ should
result to 95+% match.

Any hints/redirection are also greatly appreciated. Perhaps
there are simpler ways to achieve the same.

submitted by /u/akshayxyz

[visit reddit]

[comments]

Categories
Misc

Most tutorials seem outdated

I’ve been learning machine learning from uni, but I haven’t done
as much practical stuff as I’d like so I decided to do some in the
holidays.

Most of the books I’ve looked at (Deep learning pipeline). These
are pretty recent (2018ish) but mostly seem to either feature
tensorflow 1, need a previous version of keras to be compatible,
etc etc. Things like the Mnist dataset are also in different forms
across different versions.

For tensorflow I’ve been just using

tf.compat.v1.function() 

To just keep compatibility with tensorflow 1 so I can follow
along with the examples better, but should I just try to find
something more recent than 2018?

One of the tutorials also wanted me to run all code on an ubuntu
google cloud machine?

Are there any super good tensorflow books that are up to date
that you’d recommend? I’ve literally just been searching for deep
learning at the university online library.

It seems kinda dumb that the way the framework operates changes
so much in such a short period of time. I’m willing to put time in,
but I don’t want to go through a 500 page book to realize that
everything is now obsolete. Also how the hell do people working in
the industry deal with this, when half of the code they’ve written
is now not compatible with the main version.

submitted by /u/eht_amgine_enihcam

[visit reddit]

[comments]

Categories
Misc

AI on the Aisles: Startup’s Jetson-powered Inventory Management Boosts Revenue

Penn State University pals Brad Bogolea and Mirza Shah were living in Silicon Valley when they pitched Jeff Gee on their robotics concepts. Fortunately for them, the star designer was working at the soon-to-shutter Willow Garage robotics lab. So the three of them — Shah was also a software engineer at Willow — joined together Read article >

The post AI on the Aisles: Startup’s Jetson-powered Inventory Management Boosts Revenue appeared first on The Official NVIDIA Blog.

Categories
Misc

How to write a code that can compute and display the loss and accuracy of the trained model on the test set?

I’m rather quite embarrassed recently for flooding this forum
thread with mostly novice questions. I’m still a newbie, still
struggling to figure out how the code works in TensorFlow. Pardon
me for doing that. Is there any template code where I can compute
and display the loss and accuracy of the trained model on the test
set?

submitted by /u/edmondoh001

[visit reddit]

[comments]

Categories
Misc

(Windows) TensorFlow not detecting the cudart64_110.dll file

Yesterday, I installed the latest CUDA toolkit (11.2), but
TensorFlow said there was no cudart64_110.dll file. So, I then
installed CUDA toolkit 11.0, which has this file, but TensorFlow
still cannot find the file.

I am running Windows 10 Home Edition.

submitted by /u/Comprehensive-Ad3963

[visit reddit]

[comments]

Categories
Misc

My AI model doesn’t provide me with ‘accuracy’, it always say its 0. Why is that?

My AI model doesn’t provide me with ‘accuracy’, it always say
its 0. Why is that?

my code:

(the data i use to train is just a list of a few thousand high
prices of BTC)

# split a univariate sequence into samples
def split_sequence(sequence, n_steps):
X, y = list(), list()
for i in tqdm(range(len(sequence)), desc=’Creating training
array’):
# find the end of this pattern
end_ix = i + n_steps
# check if we are beyond the sequence/,010,0,
if end_ix > len(sequence)-1:
break
# gather input and output parts of the pattern
seq_x, seq_y = sequence[i:end_ix], sequence[end_ix]
X.append(seq_x)
y.append(seq_y)
return np.array(X), np.array(y)
def create_training_sequence(price_type=’high’, n_steps=5):
df = pd.read_csv(‘candlesticks.csv’)
df = df.drop([‘Unnamed: 0’, ‘open’, ‘close’, ‘volume’], axis=1)
if price_type == ‘high’:
sequence = df.drop([‘closeTime’, ‘low’], axis=1)
if price_type == ‘low’:
sequence = df.drop([‘closeTime’, ‘high’], axis=1)
print(sequence.head())

X, Y = split_sequence(sequence[price_type], n_steps)
print(X[1])
# reshape from [samples, timesteps] into [samples, timesteps,
features]
n_features = 1
return X, Y

import tensorflow as TheFuckImDoingHere
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense, Dropout, LSTM
from sklearn.model_selection import train_test_split
use_CPU = False
epochs = 100
n_steps = 60
batch_size = n_steps
n_features = 1
x, y = create_training_sequence(n_steps=n_steps)
x_train, x_test, y_train, y_test = train_test_split(x, y,
test_size=0.2)
x_train = x_train.reshape((x_train.shape[0], x_train.shape[1],
n_features))
x_test = x_test.reshape((x_test.shape[0], x_train.shape[1],
n_features))
print(‘————————-‘)
print(‘x_train shape: ‘+str(x_train.shape)+’, x_test shape:
‘+str(x_test.shape))
print(‘————————-‘)
if use_CPU == True:
#limit ram and cpu usage
TheFuckImDoingHere.config.threading.set_intra_op_parallelism_threads(2)
TheFuckImDoingHere.config.threading.set_inter_op_parallelism_threads(2)
# define model
model = Sequential()
model.add(LSTM(64, activation=’relu’, return_sequences=True,
input_shape=(n_steps, n_features)))
model.add(LSTM(128, activation=’relu’, return_sequences=True))
model.add(LSTM(256, activation=’relu’, return_sequences=True))
model.add(LSTM(128, activation=’relu’, return_sequences=True))
model.add(Dropout(0.2))
model.add(LSTM(64, activation=’relu’))
model.add(Dropout(0.2))
model.add(Dense(1))
model.compile(optimizer=’adam’, loss=’mse’, metrics=[‘acc’,
‘mse’])
model.summary()
#
callback = TheFuckImDoingHere.keras.callbacks.EarlyStopping(
monitor=’val_loss’, min_delta=0, patience=15, verbose=1,
mode=’min’, baseline=None, restore_best_weights=False)
#
# fit model
if use_CPU == True:
# Run inference on CPU
with TheFuckImDoingHere.device(‘/CPU:0’):
hist = model.fit(x_train, y_train, epochs=epochs,
batch_size=batch_size, validation_data=(x_test, y_test),
callbacks=[callback])
elif use_CPU == False:
# Run inference on GPU
with TheFuckImDoingHere.device(‘/GPU:0’):
hist = model.fit(x_train, y_train, epochs=epochs,
batch_size=batch_size, validation_data=(x_test, y_test),
callbacks=[callback])
prediction = model.predict(x_test[0].reshape((1, x_train.shape[1],
n_features)), verbose=0)
print(‘Prediction is: ‘ + str(prediction))
print(‘Real value is: ‘ + str(y_test[0]))
#print evaluation
loss1, acc1, mse1 = model.evaluate(x_test, y_test)
print(f”Loss is {loss1:.20E},nAccuracy is {float(acc1)*100},nMSE
is {mse1:.8E}”)

submitted by /u/Chris-hsr

[visit reddit]

[comments]

Categories
Misc

I have to say this is my biggest nightmare for this project.


I have to say this is my biggest nightmare for this project.

I was implementing a MLP neural network architecture, just
starting to work on the Flatten, Dense Layers, with the final layer
having a 10-way softmax output. The problem cropped up even without
using the to.categorical function

I run into the error when my loss function is
‘categorical_crossentropy’.


https://preview.redd.it/ai5jmj3qbs761.png?width=1148&format=png&auto=webp&s=aec4e8667d7c7ca2a7fee41eec4e1616c0a38471

And then, I changed my loss function to
‘sparse_categorical_crossentropy’,

I was running into this problem, as shown below


https://preview.redd.it/ysedtfy4fs761.png?width=1094&format=png&auto=webp&s=78e64df51c7cceb9eb9a4b9860d4ca46fc4ba056

I am stuck. I don’t know where did the error come from? Can
someone enlighten me. I really appreciated it. It’s quite a tough
journey for me in this TensorFlow journey.

Just some extra info: I’m currently working on the SVHN dataset, which
has an image dataset of over 600,000 digit images in all, and is a
harder dataset than MNIST as the numbers appear in the context of
natural scene images. SVHN is obtained from house numbers in Google
Street View images.

I set

X_train = train[‘X’]

y_train = train[‘y’]

X_test = test[‘X’]

y_test = test[‘y’]

The shape of X_train is (73257, 32, 32, 3) and y_train is
(73257, 1)

After which, I do this step,

X_train= X_train.mean(axis=-1,keepdims=True)

X_test= X_test.mean(axis=-1,keepdims=True)

So, the shape of X_train will be (73257, 32, 32, 1) and X_test
is (26032, 32, 32, 1)

Next, I did this

X_train = X_train.astype(np.float32)/255

X_test= X_test.astype(np.float32)/255

list_labels= np.unique(y_train)

list_labels

This gives me an output of : array([ 1, 2, 3, 4, 5, 6, 7, 8, 9,
10], dtype=uint8)

Then, I did this

y_train_one_hot = to_categorical(y_train-1, num_classes=10)

y_test_one_hot= to_categorical(y_test-1, num_classes=10)

For my model architecture, it’s quite simple:


https://preview.redd.it/f5q1274jds761.png?width=1028&format=png&auto=webp&s=a1363d9ec7863f4a31c93e3d6f829dd0b9d69979


https://preview.redd.it/9xs6654les761.png?width=1218&format=png&auto=webp&s=b269e6b4d467304881162580c7a1f73196e3e31b

That’s where I get this error box:

Train on 62268 samples, validate on 10989 samples Epoch 1/30 128/62268 [..............................] - ETA: 44sWARNING:tensorflow:Can save best model only with loss available, skipping. WARNING:tensorflow:Early stopping conditioned on metric `loss` which is not available. Available metrics are: 128/62268 [..............................] - ETA: 1:29 --------------------------------------------------------------------------- InvalidArgumentError Traceback (most recent call last) <ipython-input-14-b1b279107f36> in <module> 10 early_stopping= tf.keras.callbacks.EarlyStopping(monitor='loss', patience=3) 11 ---> 12 history= model.fit(X_train, y_train, batch_size=128, epochs=30, validation_split= 0.15, callbacks=[checkpoint_best,early_stopping]) /opt/conda/lib/python3.7/site-packages/tensorflow_core/python/keras/engine/training.py in fit(self, x, y, batch_size, epochs, verbose, callbacks, validation_split, validation_data, shuffle, class_weight, sample_weight, initial_epoch, steps_per_epoch, validation_steps, validation_freq, max_queue_size, workers, use_multiprocessing, **kwargs) 726 max_queue_size=max_queue_size, 727 workers=workers, --> 728 use_multiprocessing=use_multiprocessing) 729 730 def evaluate(self, /opt/conda/lib/python3.7/site-packages/tensorflow_core/python/keras/engine/training_v2.py in fit(self, model, x, y, batch_size, epochs, verbose, callbacks, validation_split, validation_data, shuffle, class_weight, sample_weight, initial_epoch, steps_per_epoch, validation_steps, validation_freq, **kwargs) 322 mode=ModeKeys.TRAIN, 323 training_context=training_context, --> 324 total_epochs=epochs) 325 cbks.make_logs(model, epoch_logs, training_result, ModeKeys.TRAIN) 326 /opt/conda/lib/python3.7/site-packages/tensorflow_core/python/keras/engine/training_v2.py in run_one_epoch(model, iterator, execution_function, dataset_size, batch_size, strategy, steps_per_epoch, num_samples, mode, training_context, total_epochs) 121 step=step, mode=mode, size=current_batch_size) as batch_logs: 122 try: --> 123 batch_outs = execution_function(iterator) 124 except (StopIteration, errors.OutOfRangeError): 125 # TODO(kaftan): File bug about tf function and errors.OutOfRangeError? /opt/conda/lib/python3.7/site-packages/tensorflow_core/python/keras/engine/training_v2_utils.py in execution_function(input_fn) 84 # `numpy` translates Tensors to values in Eager mode. 85 return nest.map_structure(_non_none_constant_value, ---> 86 distributed_function(input_fn)) 87 88 return execution_function /opt/conda/lib/python3.7/site-packages/tensorflow_core/python/eager/def_function.py in __call__(self, *args, **kwds) 455 456 tracing_count = self._get_tracing_count() --> 457 result = self._call(*args, **kwds) 458 if tracing_count == self._get_tracing_count(): 459 self._call_counter.called_without_tracing() /opt/conda/lib/python3.7/site-packages/tensorflow_core/python/eager/def_function.py in _call(self, *args, **kwds) 485 # In this case we have created variables on the first call, so we run the 486 # defunned version which is guaranteed to never create variables. --> 487 return self._stateless_fn(*args, **kwds) # pylint: disable=not-callable 488 elif self._stateful_fn is not None: 489 # Release the lock early so that multiple threads can perform the call /opt/conda/lib/python3.7/site-packages/tensorflow_core/python/eager/function.py in __call__(self, *args, **kwargs) 1821 """Calls a graph function specialized to the inputs.""" 1822 graph_function, args, kwargs = self._maybe_define_function(args, kwargs) -> 1823 return graph_function._filtered_call(args, kwargs) # pylint: disable=protected-access 1824 1825 @property /opt/conda/lib/python3.7/site-packages/tensorflow_core/python/eager/function.py in _filtered_call(self, args, kwargs) 1139 if isinstance(t, (ops.Tensor, 1140 resource_variable_ops.BaseResourceVariable))), -> 1141 self.captured_inputs) 1142 1143 def _call_flat(self, args, captured_inputs, cancellation_manager=None): /opt/conda/lib/python3.7/site-packages/tensorflow_core/python/eager/function.py in _call_flat(self, args, captured_inputs, cancellation_manager) 1222 if executing_eagerly: 1223 flat_outputs = forward_function.call( -> 1224 ctx, args, cancellation_manager=cancellation_manager) 1225 else: 1226 gradient_name = self._delayed_rewrite_functions.register() /opt/conda/lib/python3.7/site-packages/tensorflow_core/python/eager/function.py in call(self, ctx, args, cancellation_manager) 509 inputs=args, 510 attrs=("executor_type", executor_type, "config_proto", config), --> 511 ctx=ctx) 512 else: 513 outputs = execute.execute_with_cancellation( /opt/conda/lib/python3.7/site-packages/tensorflow_core/python/eager/execute.py in quick_execute(op_name, num_outputs, inputs, attrs, ctx, name) 65 else: 66 message = e.message ---> 67 six.raise_from(core._status_to_exception(e.code, message), None) 68 except TypeError as e: 69 keras_symbolic_tensors = [ /opt/conda/lib/python3.7/site-packages/six.py in raise_from(value, from_value) InvalidArgumentError: Received a label value of 10 which is outside the valid range of [0, 10). Label values: 2 4 10 8 7 4 1 7 3 2 9 3 1 1 5 10 3 1 7 2 3 4 10 5 2 5 1 5 8 9 10 9 7 5 6 2 9 5 10 2 3 3 7 6 6 1 8 8 10 5 8 10 5 4 8 5 1 6 1 4 2 2 2 1 8 6 4 2 2 1 7 3 7 1 7 2 1 10 1 5 4 1 4 4 7 2 1 3 1 3 2 6 4 7 2 3 2 2 10 3 5 3 1 1 1 6 1 5 2 7 1 1 4 2 1 10 2 3 7 5 6 8 2 6 5 1 3 5 [[node loss/dense_2_loss/SparseSoftmaxCrossEntropyWithLogits/SparseSoftmaxCrossEntropyWithLogits (defined at /opt/conda/lib/python3.7/site-packages/tensorflow_core/python/framework/ops.py:1751) ]] [Op:__inference_distributed_function_757] Function call stack: distributed_function 

I have to really thank you guys for having to read my lengthy
post. I feel sorry about that.

submitted by /u/edmondoh001

[visit reddit]

[comments]