Comments (5)
The “set_weight” method is already available. Sorry I hadn't noticed.
from tmu.
The set_TA_action and set_weight methods work fine. However, it seems one has to perform training of the TM (in my case the TMCoalescedClassifier) before the methods can be applied. This is possibly difficult to avoid. If that is the case, one can perform only a short training phase (with only a few samples) only to get all the clause_banks etc. defined, before one "loads" an existing model to the TM.
from tmu.
Currently, we need to run .fit before the model is initialized.
But we might be able to do the following, if @olegranmo:
Perhaps we should make a parameter: input_shape in the constructor of TM models. then we can initialize models before fit is executed.
What do you think?
from tmu.
It absolutely makes sense to add shape. What is extracted from the data is simply the number of features and the number of classes, which is needed to set up the data structures
from tmu.
The following code example seems to work well back and forth, and utilizes .csv model files. Here I do not use the TA_action_data when loading a model, just the TA_state_data. I am sure there can be more elegant ways to implement things, but this is something that is easy to understand and use.
If a model can be loaded without performing the fit method first, this can be time saving for various experiments.
####################################################
#EXTRACT a model from a trained TM (TMCoalescedClassifier):
####################################################
numberofclasses = 10
numberofclauses = 128
numberofliterals=272
TA_action_array= np.zeros((numberofclauses, numberofliterals), int)
TA_state_array= np.zeros((numberofclauses, numberofliterals), int)
for k in range (numberofclauses):
for b in range (numberofliterals):
TA_state_array[k,b]= tm.get_ta_state(k,b)
if tm.get_ta_action(k,b) == True:
TA_action_array[k,b]=1
weightarray=np.zeros((numberofclasses, numberofclauses), int)
for g in range (numberofclasses):
for c in range (numberofclauses):
weightarray[g,c]=tm.get_weight(g,c)
#SAVE MODEL:
savetxt('TA_action_data.csv', TA_action_array, delimiter=',')
savetxt('TA_state_data.csv', TA_state_array, delimiter=',')
savetxt('weight_data.csv', weightarray, delimiter=',')
#LOAD MODEL:
weightarray = loadtxt('weight_data.csv', delimiter=',')
#TA_action_array = loadtxt('TA_action_data.csv', delimiter=',')
TA_state_array = loadtxt('TA_state_data.csv', delimiter=',')
for k in range (numberofclauses):
for b in range (numberofliterals):
tm.set_ta_state(k, b, int(TA_state_array[k,b]))
for g in range (numberofclasses):
for c in range (numberofclauses):
tm.set_weight(g, c, Weightarray[g,c])
from tmu.
Related Issues (20)
- ModuleNotFoundError: No module named 'tmu.tmulib' HOT 3
- ModuleNotFoundError: No module named 'tmu.tmulib' HOT 1
- Saving and loading trained classifiers HOT 3
- Return of class_sums also for the TMCoalescedClassifier HOT 1
- Support for integrated hyperparam search
- Issues with import and thresholding of FashionMNIST and KuzushijiMNIST datasets
- Request for maximum/minimum weight parameter
- TMComposite merge HOT 1
- Add support for training multiple TMs with common feedback signals.
- Compilation error on Mac HOT 3
- IMDbWordEmbeddingDemo.py not working HOT 1
- AutoEncoder has stopped learning
- Int type used as dataset index - does not work with large datasets
- Build error on Linux Ubuntu using pip3 install -e . HOT 1
- Type conversion of X to uint32 missing in fit HOT 5
- If all classes are '0' in Y, fit goes into infinite loop HOT 1
- get_encoded_data does not refresh with new data HOT 2
- ndarray is not C-contiguous
- Sparse not working HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tmu.