Note: I didn't write the code, here is the code I'm trying to modify this and
my repository is here.
I'm currently trying to convert a singular variable regression to a multi-variable DNN regression. Line 76 in regressor_full.py always returns an error about incompatible shape. I've changed the input to the shape of 11, however, I don't know to change the output layer to 11 too.
Line 76 : feature_columns = [tf.feature_column.numeric_column('X', shape=(11,))]
However, I'm sure that the input and output tensors aren't the only 2 things that have to be changed. Could you guys help me with adapting the repo? Thank you
To adapt the regressor for 11 targets/outputs, change the value of label_dimension to 11 as follows [Line #97 in your code]:
regressor = skflow.DNNRegressor(feature_columns=feature_columns,
label_dimension=11,
hidden_units=hidden_layers,
model_dir=MODEL_PATH,
dropout=dropout,
config=test_config)
Successful training log:
Related
I have a Gaussian mixture model defined in Pytorch as below:
mix = D.Categorical(torch.rand(2,5,1))
comp = D.Normal(torch.randn(1), torch.rand(1))
#print(mix.logits.shape,comp.batch_shape)
gmm2 = D.MixtureSameFamily(mix, comp)#multiv
What I want to achieve is to have a 5-component mixture of 2-component mixtures of univariate Gaussians. I need the Gaussians to be univariate, therefore I don't want to define them as bivariate. Essentially, I want to define a multivariate mixture of univariate Gaussians instead of a mixture of multivariate Gaussians.
Running the above code, the mixture model is constructed successfully, but when I want to sample from it I get the following error:
RuntimeError: Index tensor must have the same number of dimensions as input tensor
The error happens in this line samples = torch.gather(comp_samples, gather_dim, mix_sample_r) in the mixture_same_family class. I understand the problem with the gather function but am out of ideas how to fix it. I'd appreciate any feedback on this.
I am making a logistic regression model and have separate training and testing dataset file. All my code works perfect on fitting and prediction of model, but when I apply (Classification_report(y, prediction))
then it shows (Found input variables with inconsistent numbers of samples: [889, 418]) error. My testing dataset have only 418 rows while training has 889 rows.
Please tell me how can I fix this??
When the error is outputting "inconsistent number of samples", it means that your y and prediction variables have a different first dimension. In your case, one of the variables have their first dimension as 889 and the second variable has the first dimension as 418.
As for fixing this, this could be solved with a simple np.reshape(), however if that doesn't work you may have to look at your code again to find out where you might have messed up in the predictions and/or in the y variable
The last layer it has is a layer whose output is a 13x13x75 matrix, when it should be 1x10 since 10 is the number of output classes.
It lacks layers, including the layer logits. When you download the model it comes with some python files to use it and in these files you see all the processing that must be done to get to a 1x10 matrix.
The point is that this code should not exist and everything must be within the model.
What is the file with the .pb extension?
Does anyone know what could be happening?
Sorry about the confusion.
What is the file with the .pb extension?
That is the TensorFlow model you load to do inferencing.
Guessing from the 13 x 13 x 75 output you received you created a Object-Detection model(OD) but you were expecting a 1 x 10 output indicating to me that you want a multi-label model.
Multi-Label: Returns the 1x10 vector you are expecting.
OD: Is meant to provide bounding box info as well as confidence; it requires custom code to compute that is not supported in the pipeline; that is why the final processing needs to be done in the python code ('object_detection.py').
kurt,
I am currently trying to implement GoogLeNet architecture (InceptionV1) in Keras using theano backend, as I want to generate features for CUB dataset using GoogLeNet model.
I found an implementation in Keras here.
However, it is based on the earlier version of Keras and I had to make changes in the layers as per Keras version 2.
Now, the model is getting built correctly. However, the predict() function is failing with the error as
ValueError: CorrMM images and kernel must have the same stack size
So, I started looking at the original paper and correlating the layers mentioned in the paper with the implemented one.
So, here I found first layer to have output as expected as 112x112x64 with the input as 224x224x3.
However, when I tried to calculate the expected output dimensions as per the formula given in Stanford University tutorial page, it is different from the actual output which I received from the Keras code, though this is what is the expected output as per the GoogLeNet paper. i.e. as per the formula mentioned on the Stanford page Output height or length = ((Input height or length - filter size + 2 * Padding) / Stride) + 1
As per above equation, the output dimension comes in fraction which is not valid and to get the expected dimension as per the formula, input needs to be of shape 227x227x3. However, in Keras, with this input, output comes as 114x114x64.
Does Keras calculate the output dimensions in some different way or am I missing out on something?
Somehow I could make it work yesterday by removing few lines of code from the model which was making it to change the dimensions. (Possibly it was required by earlier version of Keras and Theano)
Also, contrary to the one mentioned in the paper, I changed patch size of MaxPooling2D() function from 3x3 to 2x2 which is the only way to achieve the desired output dimensions in GoogLeNet architecture. With input shape 224x224 and applying max pooling with patch size 2x2 and stride 2x2, its dimensions gets halved and we can get the desired output shape.
I am not sure why equation of output dimensions based on input, filter, padding and stride as parameters are not applicable here.
I'm new to cntk and python. I have done machine learning in c# over the years with various libraries.
To help me learn cntk and python I doing a simple classification project with UCI wine data set. Right now I am only doing one hidden layer, I do plan to add more hidden layers after I get one hidden layer working.
I am having problems with creating a hidden Dense layer with dtype of numpy.float64. I know float32 is faster. I want to have my underlining data as float64 because of future projects that is a requirement.
I have searched the internet for help with no avail for answers. The last thing I have tried is creating the inputs with dtype=numpy.float64 and passing inputs to Dense, but that did not work either. In the past I have tried "with cntk.layers.default_options(dtype=numpy.float64)" inside a function but it does not accept numpy.float64 with or without a name. I have also tried calling update_signature(numpy.float64) on what is returned from Dense and I get the same error. I would tell you other things I have tried, but I honestly don't remember right now.
Here is my latest code:
inputsCount = 11
classesCount = 2
inputs = cntk.input_variable(shape=(inputsCount), dtype=numpy.float64)
model = cntk.layers.Dense(classesCount, activation=None)(inputs)
This is the error I get with it:
ValueError: Primitive op 'Times' passed operands 'Parameter('W', [],
[? x 2]), Placeholder('Placeholder135', [#], [11])' with different
DataTypes 'Float' and 'Double'.
Can you try this?
inputsCount = 11
classesCount = 2
with cntk.default_options(dtype=numpy.float64):
inputs = cntk.input_variable(shape=(inputsCount))
model = cntk.layers.Dense(classesCount, activation=None)(inputs)