machine-learning

ValueError: Input 0 of layer sequential is incompatible with the layer: : expected min_ndim=4, found ndim=2. Full shape received: [None, 2584]

只愿长相守 提交于 2021-02-09 05:55:34
问题 I'm working in a project that isolate vocal parts from an audio. I'm using the DSD100 dataset, but for doing tests I'm using the DSD100subset dataset from I only use the mixtures and the vocals. I'm basing this work on this article First I process the audios to extract a spectrogram and put it on a list, with all the audios forming four lists (trainMixed, trainVocals, testMixed, testVocals). Like this: def to_spec(wav, n_fft=1024, hop_length=256): return librosa.stft(wav, n_fft=n_fft, hop

How to apply a ScikitLearn classifier to tiles/windows in a large image

社会主义新天地 提交于 2021-02-08 20:53:36
问题 Given is a trained classifer in scikit learn, e.g. a RandomForestClassifier . The classifier has been trained on samples of size e.g. 25x25. How can I easily apply this to all tiles/windows in a large image (e.g. 640x480)? What I could do is (slow code ahead!) x_train = np.arange(25*25*1000).reshape(25,25,1000) # just some pseudo training data y_train = np.arange(1000) # just some pseudo training labels clf = RandomForestClassifier() clf.train( ... ) #train the classifier img = np.arange(640

Load model with ML.NET saved with keras

倖福魔咒の 提交于 2021-02-08 19:57:19
问题 I have a Neural Network implemented in Python with Keras. Once I have trained it I have exported the model and I have got two files: model.js and model.h5. Now I want to classify in real time inside a .NET project and I want to use the trained Neural Network for it. Is there a way in ML.NET of loading the model and trained weights exported with python into a model object? I have seen in the documentation[1] that a previous saved model can be loaded, but apparently is storage in a .zip and I

fastest way to load images in python for processing

丶灬走出姿态 提交于 2021-02-08 15:36:15
问题 I want to load more than 10000 images in my 8gb ram in the form of numpy arrays.So far I have tried cv2.imread,keras.preprocessing.image.load_image,pil,imageio,scipy.I want to do it the fastest way possible but I can't figure out which on is it. 回答1: One of the Fastest way is to get your multiprocessors do your job in Parallel it asks for parallelisation of your desired job, it brings multiple processors to work on your tasks at the same time when concurrent running isn't an issue. This

get_dummies(), Exception: Data must be 1-dimensional

◇◆丶佛笑我妖孽 提交于 2021-02-08 15:11:19
问题 I have this data I am trying to apply this: one_hot = pd.get_dummies(df) But I get this error: Here is my code up until then: # Import modules import pandas as pd import numpy as np import matplotlib.pyplot as plt from sklearn import tree df = pd.read_csv('AllMSAData.csv') df.head() corr_matrix = df.corr() corr_matrix df.describe() # Get featurs and targets labels = np.array(df['CurAV']) # Remove the labels from the features # axis 1 refers to the columns df = df.drop('CurAV', axis = 1) #

Tensorflow failed to create a newwriteablefile when retraining inception

故事扮演 提交于 2021-02-08 12:59:13
问题 I am following this tutorial: https://codelabs.developers.google.com/codelabs/tensorflow-for-poets/?utm_campaign=chrome_series_machinelearning_063016&utm_source=gdev&utm_medium=yt-desc#4 I am running this part of the code: python retrain.py \ --bottleneck_dir=bottlenecks \ --how_many_training_steps=500 \ --model_dir=inception \ --summaries_dir=training_summaries/basic \ --output_graph=retrained_graph.pb \ --output_labels=retrained_labels.txt \ --image_dir=flower_photos Here is the error that

Use Artificial Intelligence to predict next number (n+1) in a sequence

半腔热情 提交于 2021-02-08 12:09:45
问题 The AI must predict the next number in a given sequence of incremental integers using Python, but so far I haven't gotten the intended result. I tried changing the learning rate and iterations but so far without any luck. The next number is supposed to be predicted based on this PATTERN : First number in the sequence (1) is a random int in the interval of [2^0 (current index), 2^1(next index) and so on so forth... The AI should be able to make the decision of which number to choose from the

Tensorflow 2.0: How can I fully customize a Tensorflow training loop like I can with PyTorch?

假装没事ソ 提交于 2021-02-08 11:42:17
问题 I used to use Tensorflow a lot before, but moved over to Pytorch because it was just a lot easier to debug. The nice thing I found with PyTorch is that I have to write my own training loop, so I can step through the code and find errors. I can fire up pdb and check the tensor shapes and transformations, etc., without difficulty. In Tensorflow I was using the model.fit() function all the time, and so any error message I got was like 6 pages of C code where the error message did not give me any

Finetuning VGG-16 on GPU in Keras: memory consumption

血红的双手。 提交于 2021-02-08 11:20:20
问题 I'm fine-tuning VGG-16 for my task. The idea is that I load the pretrained weights, remove the last layer (which is softmax with 1000 outputs) and replace it with a softmax with a few outputs. Then I freeze all the layers but the last and train the model. Here is the code that builds the original model and loads the weights. def VGG_16(weights_path=None): model = Sequential() model.add(ZeroPadding2D((1,1),input_shape=(224,224,3))) model.add(Conv2D(64, (3, 3), activation='relu')) model.add

partially define initial centroid for scikit-learn K-Means clustering

孤街醉人 提交于 2021-02-08 10:57:22
问题 Scikit documentation states that: Method for initialization: ‘k-means++’ : selects initial cluster centers for k-mean clustering in a smart way to speed up convergence. See section Notes in k_init for more details. If an ndarray is passed, it should be of shape (n_clusters, n_features) and gives the initial centers. My data has 10 (predicted) clusters and 7 features. However, I would like to pass array of 10 by 6 shape, i.e. I want 6 dimensions of centroid of be predefined by me, but 7th