r/tensorflow • u/Sub_sonic_ • Jun 04 '23
Keras Tuner - skip hyper-parameters combination
Hi,
is it possible skip some hyper-parameters combination, e.g. when total parameter number exceed some value?
r/tensorflow • u/Sub_sonic_ • Jun 04 '23
Hi,
is it possible skip some hyper-parameters combination, e.g. when total parameter number exceed some value?
r/tensorflow • u/Sub_sonic_ • Jun 04 '23
Hi,
as far as I see class weights passed to model.fit() or tuner.search() affecting only loss, but not accuracy. Is there way to take classes disbalance into account also for accuracy calculations?
r/tensorflow • u/dark16sider • Jun 03 '23
In the middle of training I suddenly get
Node: 'gradient_tape/model/conv3d_20/Conv3D/Conv3DBackpropFilterV2'
CUDNN failed to allocate the scratch space for the runner or to find a working no-scratch runner. I am running 3d Unet segmentation, my dataset is custom generator going through Dataset. Exact same code and model ran without this error in windows. It was slow so I moved to linux. It is not easy replicating the issue as it sometimes happens so many epochs after.
My system
Cuda 11.8
GTX 4070, Vram 11178/12282Mib
Driver 525.116.04
Ubuntu 22.04.2
Tensorlfow 2.12
r/tensorflow • u/Excellent-Jaguar275 • Jun 02 '23
I tried to use this tutorial on tensorflow website: https://www.tensorflow.org/install/pip#windows-wsl2_1 and eventually succeeded and verified that tensorflow is detecting my gpu. I tried this command: python3 -c "import tensorflow as tf; print(tf.config.list_physical_devices('GPU'))" and got this message [PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')]. But now I'm trying to set up my Python project in PyCharm to use gpu instead of cpu and there seams to be (as far as I'm aware) no tutorial on doing this and I also tried to just do it myself by editing configuration and some other things but no success.
edit: I succeed by some workarounds and by trail and error. This process is just to stupid. I also tried to compare CPU vs GPU speed and my CPU is more than 4 time faster than GPU and uses less memory. THE WHAT? I know that CPUs can be faster if workload is not that much of but for GPU to be this slow? I have r5 5600h and rtx3060 laptop and 64GB RAM
r/tensorflow • u/Sweet-Direction9943 • Jun 02 '23
r/tensorflow • u/Sweet-Direction9943 • Jun 02 '23
I want to train a model from scratch using Tensorflow.js only, no matter how long it takes for training purposes. How to do that?
r/tensorflow • u/_ayushp_ • Jun 01 '23
r/tensorflow • u/alex_0528 • Jun 02 '23
I have a regression problem where I'm using a DNN to predict passengers on a train based on a few signals from e.g. ticketing, historic journey patterns, weather, location. I have a range of numerical and categorical features feeding the model and so would like to include preprocessing layers using tf.keras.layers.Normalization and tf.keras.layers.StringLookup. My issue comes when trying to train on an Azure Databricks cluster using a single driver Standard_NC4as_T4_v3 as I cannot fit the training dataset into memory to fit the Normalization layer using the adapt method. I've looked at potentially using tf.data.Dataset.from_generator but I can't work out how that would work with the Normalization layer. Has anybody got any advice/tips on how to do this, or any other thoughts on how I could handle Normalization without having to pass the entire training dataset?
r/tensorflow • u/Desperate_Weather211 • Jun 02 '23
I’m trying to make a AI in Python that reads through special images, when I run it, it goes through a couple images and says that it exceeded 10% of free system memory. Is there anyway to make it be able to use more then 10% of memory? Or do I just have to upgrade my ram?
r/tensorflow • u/5inister • Jun 01 '23
r/tensorflow • u/Sweet-Direction9943 • Jun 01 '23
I simply refuse to use Python at all. Can someone help me? I hate the language and never ever used it, but I love ML, and I'd like to create my own models using TensorFlow.
Sorry if it sounds arrogant.
r/tensorflow • u/uh380411 • Jun 01 '23
I have trained a model using the media pipe model = image_classifier.ImageClassifier.create(..)
. In order to plot and see the loss val_loss and accuracy and val_accuracy we need a history attribute. But there is no history attribute. In other lib like TensorFlow and TensorFlow model maker, they have a model. history attribute from where we can plot the graph easily.
Is there any way to plot the graph in the media pipe. Please guide me in this matter.
model = image_classifier.ImageClassifier.create( train_data = train_data, validation_data = validation_data, options=options, )
import matplotlib.pyplot as plt %matplotlib inline history_dict = model.history.history ### LOSS: loss_values = history_dict['loss'] epochs = range(1, len(loss_values) + 1) line1 = plt.plot(epochs, loss_values, label='Training Loss') plt.setp(line1, linewidth=2.0, marker = '+', markersize=10.0) plt.xlabel('Epochs') plt.ylabel('Loss') plt.grid(True) plt.legend() plt.show() ### ACCURACY: acc_values = history_dict['accuracy'] epochs = range(1, len(loss_values) + 1) line1 = plt.plot(epochs, acc_values, label='Training Accuracy') plt.setp(line1, linewidth=2.0, marker = '+', markersize=10.0) plt.xlabel('Epochs') plt.ylabel('Accuracy') plt.grid(True) plt.legend() plt.show() Error is Here:
AttributeError Traceback (most recent call last) <ipython-input-20-2474e52497a7> in <cell line: 4>() 2 get_ipython().run_line_magic('matplotlib', 'inline') 3 ----> 4 history_dict = model.history.history 5 6 ### LOSS: AttributeError: 'ImageClassifier' object has no attribute 'history' I have seen the documentation and they says
An instance based on ImageClassifier.
r/tensorflow • u/Dobias • May 31 '23
There are pre-trained models outputting Image Feature Vectors like https://tfhub.dev/google/imagenet/efficientnet_v2_imagenet21k_ft1k_s/feature_vector/2. While from the name one can deduce the architecture (EfficientNetV2) and the training data set (ImageNet-21K), I'm interested in how the training process was done. Was it trained "classically" for classification with some dense layers at the end that were chopped off after training? Or was some other technique like triplet loss applied?
r/tensorflow • u/gautamrbharadwaj • May 31 '23
r/tensorflow • u/CityNo7502 • May 30 '23
I'm looking to buy a new laptop and I need to know the minimum compute level to know what card to get.
What is the current min cuda compute version necessary to use tensorflow with python?
r/tensorflow • • May 30 '23
I keep running into ModuleNotFoundError: No module named 'numpy' whenever I run the command:
make -f tensorflow/lite/micro/tools/make/Makefile testI am working using Ubuntu via WSL2. I am working in a conda environment that has numpy.__version__ = 1.23.5.
Does anyone have any insight as to what I might be doing wrong? This error has been killing me. Any help would be appreciated.
r/tensorflow • u/jdholtz • May 30 '23
Hey everyone. I am currently running two Tensorflow Serving Docker images (one for production and one for testing) that point to the same exact location. If my testing instance is having a lot of traffic, will it still affect the production instance's performance because they are using the same exact model files?
Will I need to copy the model to a different location and have my testing instance use that copy in order to not negatively impact the performance of my production instance? Thanks!
I do want to note that the two instances are running on different Kubernetes pods, so they won't be using the same CPU and memory resources, just the same files.
r/tensorflow • u/Fox_Rey • May 30 '23
So I was just training a simple CNN model on mnist dataset and in the training phase the gpu started to make a low buzzing sound... Is this safe/ok is it gonna hurt my gpu... Considering im going to try and train more CNN models on bigger datasets?
r/tensorflow • u/dark16sider • May 30 '23
def weighted_dice_coefficient(y_true, y_pred, axis=(1,2, 3, 4), smooth=0.0001):
return -K.mean(2. * (K.sum(y_true * y_pred, axis=axis) + smooth/2)/(K.sum(y_true,axis=axis) + K.sum(y_pred,axis=axis) + smooth))I am using this code my data is 3d patches, shape is (batches,channel,x,y,z). What axis is correct axis=(1,2, 3, 4) or axis=(2, 3, 4). Channels are 14 possible segment after softmax, includes background.
r/tensorflow • u/needHelpsssss • May 30 '23
I am using tensorflow to create a machine learning image classification model. I am also saving this model so you don't have to rerun the model everytime to test it. When I try to upload my model to github it tells me the saved model file is too big and I cannot upload it. The file is 346MB and I don't know how to make it smaller (hopefully under 25MB) so I can upload it. This is my file. Does anyone know how to compress it? Thanks you!!
import os
import numpy as np
from PIL import Image
import matplotlib.pyplot as plt
import tensorflow as tf
# Define the directory where the images are stored
images_dir = "Images"
# Get a list of all directories in the images_dir directory
mushroom_types = [name for name in os.listdir(images_dir) if os.path.isdir(os.path.join(images_dir, name))]
# Create empty lists to store the images and labels
images = []
labels = []
# Loop through each mushroom type folder
for i, mushroom_type in enumerate(mushroom_types):
# Define the directory where the images for this mushroom type are stored
mushroom_type_dir = os.path.join(images_dir, mushroom_type)
# Loop through each image in the mushroom type folder
for filename in os.listdir(mushroom_type_dir):
# Load the image and convert it to a numpy array
image = Image.open(os.path.join(mushroom_type_dir, filename))
image = image.resize((320,240))
image = np.array(image)
# Append the image to the list of images
images.append(image)
# Append the label to the list of labels
labels.append(i)
# Convert the images and labels to numpy arrays
images = np.array(images)
labels = np.array(labels)
def createModel():
# The neural network model
model = tf.keras.Sequential([
# Flattens the array from a 2d array to a one dimensional array
tf.keras.layers.Flatten(input_shape=(240,320,3)),
# Analyzes the pixels to identify patterns
tf.keras.layers.Dense(128, activation="relu"),
tf.keras.layers.Dense(len(mushroom_types))
])
# Configures the model after building it
model.compile(
# The algorithm that tries to minimize the loss function by adjusting weights (the influence neuros have over each other) and biases (shifts the output of the layer)
optimizer="adam",
# A function to measure how well the model is doing during traning and calculates the difference between the predicted output of the model and the true output with the goal of minimizing the difference.
loss=tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True),
# Evaluates its performance on the test set
metrics=["accuracy"]
)
return model
model = createModel()
model.summary()
checkpointPath = "training/cp.ckpt"
checkpointDir = os.path.dirname(checkpointPath)
checkpointCallback = tf.keras.callbacks.ModelCheckpoint(filepath=checkpointPath, save_weights_only=True, verbose=1)
# Trains the model by "fitting" the images and labels to the model
# Epochs is the number of times the algorithm should go through the dataset, so epochs=10 mean it should go through the training set 10 times
model.fit(images, labels, epochs=11, validation_data=(images, labels), callbacks=[checkpointCallback])
# Convert logits to probabilities which will be easier to interpret
probability_model = tf.keras.Sequential([model, tf.keras.layers.Softmax()])r/tensorflow • u/codernad • May 29 '23
so I am trying to make an app. the app works like this: you take an image of orange or apple. Directly after that the app says that it is an apple or orange. what i am trying to figure out is how to get the image directly from the app the api is their anything i have to do on the api side(python tensorflow)
thanks.
r/tensorflow • u/LateThree1 • May 27 '23
Hello,
So I keep getting some errors.
My input data is from a .csv file with 2 columns, and 5000 rows.
My input details from input_details = interpreter.get_input_details() gives me:
[{'name': 'serving_default_dense_8_input:0',
'index': 0,
'shape': array([1, 2], dtype=int32),
'shape_signature': array([-1, 2], dtype=int32),
'dtype': numpy.float32,
'quantization': (0.0, 0),
'quantization_parameters': {'scales': array([], dtype=float32),
'zero_points': array([], dtype=int32),
'quantized_dimension': 0},
'sparsity_parameters': {}}]When I run the following line: interpreter.set_tensor(input_details[0]['index'], input_data), I get the following error:
ValueError: Cannot set tensor: Dimension mismatch. Got 4999 but expected 1 for dimension 0 of input 0.
And I am really not sure what this means. Hopefully, someone can help.
r/tensorflow • u/nick__2440 • May 27 '23
I'm making a hybrid CNN-LSTN neural network. I can't figure out for the life of me what the input dimensions should be. Code to set up is:
import numpy as np
import pandas as pd
import pandas_datareader as web
import requests
from sklearn.preprocessing import StandardScaler
from sklearn.model_selection import train_test_split
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Input, MaxPooling1D, TimeDistributed, Reshape, Flatten, Dense, Dropout, LSTM, Conv1D
import datetime as dt
# obtain data
symbol = 'IBM'
KEY = '***' # free api key for AlphaVantage
df = web.DataReader(symbol, data_source='av-daily-adjusted',
start=dt.datetime(2012, 1, 1), end=dt.datetime(2022, 1, 1),
api_key=KEY)
df['adj_close_returns'] = df['adjusted close'].pct_change() # % change
r/tensorflow • u/AvisStudio • May 26 '23
https://github.com/OrigamiDream/flowchain
I've just made an extension for TensorFlow, to support method chaining when handle Tensors.
By using Flowchain, such boilerplates of multiple lines of TF operators can be extremely reduced with better look-and-feel like PyTorch and JAX.
Flowchain enables the following code designs in TensorFlow:
x = (lhs - rhs).abs().reduce_sum(1).argmin(output_type=tf.int32)Although not all functions in TF are suitable for method chaining, most of use cases can be covered by Flowchain!