forked from freudenreichan/info2Praktikum-NeuronalesNetz
Compare commits
No commits in common. "5fcc3cd042ad6cb28b2781f832a034604d40e2a2" and "3de79e2b83420a26b3a7ad0c1f6648623e4f5190" have entirely different histories.
5fcc3cd042
...
3de79e2b83
Binary file not shown.
@ -7,23 +7,16 @@
|
|||||||
#define FILE_HEADER_STRING "__info2_image_file_format__"
|
#define FILE_HEADER_STRING "__info2_image_file_format__"
|
||||||
|
|
||||||
// TODO Implementieren Sie geeignete Hilfsfunktionen für das Lesen der Bildserie aus einer Datei
|
// TODO Implementieren Sie geeignete Hilfsfunktionen für das Lesen der Bildserie aus einer Datei
|
||||||
GrayScaleImage readImage()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO Vervollständigen Sie die Funktion readImages unter Benutzung Ihrer Hilfsfunktionen
|
// TODO Vervollständigen Sie die Funktion readImages unter Benutzung Ihrer Hilfsfunktionen
|
||||||
GrayScaleImageSeries *readImages(const char *path)
|
GrayScaleImageSeries *readImages(const char *path)
|
||||||
{
|
{
|
||||||
GrayScaleImageSeries *series = NULL;
|
GrayScaleImageSeries *series = NULL;
|
||||||
FILE *file = fopen("mnist_test.info2","rb");
|
|
||||||
char headOfFile;
|
|
||||||
series = malloc();
|
|
||||||
return series;
|
return series;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO Vervollständigen Sie die Funktion clearSeries, welche eine Bildserie vollständig aus dem Speicher freigibt
|
// TODO Vervollständigen Sie die Funktion clearSeries, welche eine Bildserie vollständig aus dem Speicher freigibt
|
||||||
void clearSeries(GrayScaleImageSeries *series)
|
void clearSeries(GrayScaleImageSeries *series)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
6
matrix.h
6
matrix.h
@ -6,14 +6,12 @@
|
|||||||
typedef float MatrixType;
|
typedef float MatrixType;
|
||||||
|
|
||||||
// TODO Matrixtyp definieren
|
// TODO Matrixtyp definieren
|
||||||
typedef struct
|
typedef struct{
|
||||||
{
|
|
||||||
unsigned int rows;
|
unsigned int rows;
|
||||||
unsigned int cols;
|
unsigned int cols;
|
||||||
MatrixType *data;
|
MatrixType *data; //Zeiger auf Speicher (Reihen*Spalten)
|
||||||
} Matrix;
|
} Matrix;
|
||||||
|
|
||||||
|
|
||||||
Matrix createMatrix(unsigned int rows, unsigned int cols);
|
Matrix createMatrix(unsigned int rows, unsigned int cols);
|
||||||
void clearMatrix(Matrix *matrix);
|
void clearMatrix(Matrix *matrix);
|
||||||
void setMatrixAt(MatrixType value, Matrix matrix, unsigned int rowIdx, unsigned int colIdx);
|
void setMatrixAt(MatrixType value, Matrix matrix, unsigned int rowIdx, unsigned int colIdx);
|
||||||
|
|||||||
@ -71,32 +71,6 @@ void test_addFailsOnDifferentInputDimensions(void)
|
|||||||
TEST_ASSERT_EQUAL_UINT32(0, result.cols);
|
TEST_ASSERT_EQUAL_UINT32(0, result.cols);
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_addSupportsBroadcasting(void)
|
|
||||||
{
|
|
||||||
MatrixType buffer1[] = {1, 2, 3, 4, 5, 6};
|
|
||||||
MatrixType buffer2[] = {7, 8};
|
|
||||||
Matrix matrix1 = {.rows=2, .cols=3, .buffer=buffer1};
|
|
||||||
Matrix matrix2 = {.rows=2, .cols=1, .buffer=buffer2};
|
|
||||||
|
|
||||||
Matrix result1 = add(matrix1, matrix2);
|
|
||||||
Matrix result2 = add(matrix2, matrix1);
|
|
||||||
|
|
||||||
float expectedResults[] = {8, 9, 10, 12, 13, 14};
|
|
||||||
|
|
||||||
TEST_ASSERT_EQUAL_UINT32(matrix1.rows, result1.rows);
|
|
||||||
TEST_ASSERT_EQUAL_UINT32(matrix1.cols, result1.cols);
|
|
||||||
TEST_ASSERT_EQUAL_UINT32(matrix1.rows, result2.rows);
|
|
||||||
TEST_ASSERT_EQUAL_UINT32(matrix1.cols, result2.cols);
|
|
||||||
|
|
||||||
TEST_ASSERT_EQUAL_INT(sizeof(expectedResults)/sizeof(expectedResults[0]), result1.rows * result1.cols);
|
|
||||||
TEST_ASSERT_EQUAL_FLOAT_ARRAY(expectedResults, result1.buffer, result1.cols * result1.rows);
|
|
||||||
TEST_ASSERT_EQUAL_INT(sizeof(expectedResults)/sizeof(expectedResults[0]), result2.rows * result2.cols);
|
|
||||||
TEST_ASSERT_EQUAL_FLOAT_ARRAY(expectedResults, result2.buffer, result2.cols * result2.rows);
|
|
||||||
|
|
||||||
free(result1.buffer);
|
|
||||||
free(result2.buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_multiplyReturnsCorrectResults(void)
|
void test_multiplyReturnsCorrectResults(void)
|
||||||
{
|
{
|
||||||
MatrixType buffer1[] = {1, 2, 3, 4, 5, 6};
|
MatrixType buffer1[] = {1, 2, 3, 4, 5, 6};
|
||||||
@ -164,7 +138,7 @@ void test_setMatrixAtFailsOnIndicesOutOfRange(void)
|
|||||||
Matrix matrixToTest = {.rows=2, .cols=3, .buffer=buffer};
|
Matrix matrixToTest = {.rows=2, .cols=3, .buffer=buffer};
|
||||||
|
|
||||||
setMatrixAt(-1, matrixToTest, 2, 3);
|
setMatrixAt(-1, matrixToTest, 2, 3);
|
||||||
TEST_ASSERT_EQUAL_FLOAT_ARRAY(expectedResults, matrixToTest.buffer, sizeof(buffer)/sizeof(MatrixType));
|
TEST_ASSERT_EQUAL_FLOAT_ARRAY(expectedResults, matrixToTest.buffer, matrixToTest.cols * matrixToTest.rows);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setUp(void) {
|
void setUp(void) {
|
||||||
@ -185,7 +159,6 @@ int main()
|
|||||||
RUN_TEST(test_clearMatrixSetsMembersToNull);
|
RUN_TEST(test_clearMatrixSetsMembersToNull);
|
||||||
RUN_TEST(test_addReturnsCorrectResult);
|
RUN_TEST(test_addReturnsCorrectResult);
|
||||||
RUN_TEST(test_addFailsOnDifferentInputDimensions);
|
RUN_TEST(test_addFailsOnDifferentInputDimensions);
|
||||||
RUN_TEST(test_addSupportsBroadcasting);
|
|
||||||
RUN_TEST(test_multiplyReturnsCorrectResults);
|
RUN_TEST(test_multiplyReturnsCorrectResults);
|
||||||
RUN_TEST(test_multiplyFailsOnWrongInputDimensions);
|
RUN_TEST(test_multiplyFailsOnWrongInputDimensions);
|
||||||
RUN_TEST(test_getMatrixAtReturnsCorrectResult);
|
RUN_TEST(test_getMatrixAtReturnsCorrectResult);
|
||||||
|
|||||||
@ -1,29 +0,0 @@
|
|||||||
Inhalte: Dynamische Speicherverwaltung, Strukturen, Dateien lesen.
|
|
||||||
|
|
||||||
Ziel: Die Bilder aus mnist_test.info 2 auslesen
|
|
||||||
|
|
||||||
Struktur für einlesen des Strings am Anfang der Datei:
|
|
||||||
int AnzahlBilder
|
|
||||||
int breiteBilder
|
|
||||||
int LaengeBilder
|
|
||||||
|
|
||||||
Struktur für Bilder:
|
|
||||||
unsinged int array Breite * Höhe
|
|
||||||
unsigned int Klasse (Label 0 - 9)
|
|
||||||
|
|
||||||
|
|
||||||
Speicher für Bilder dynamisch allokieren
|
|
||||||
|
|
||||||
GrayScaleImageSeries:
|
|
||||||
datei einlesen
|
|
||||||
header String aus der Datei lesen
|
|
||||||
mit header String den benötigten Speicher freigeben
|
|
||||||
in den Speicher die Datei einschreiben (mit Hilfsfunktion)
|
|
||||||
|
|
||||||
Hilfsfunktion (saveFile)
|
|
||||||
gehe zum Anfang des Strings
|
|
||||||
speicher alles der Reihe nach ein
|
|
||||||
|
|
||||||
clearSeries:
|
|
||||||
pointer der be malloc kommt nehemen
|
|
||||||
free()
|
|
||||||
Loading…
x
Reference in New Issue
Block a user